solve-1.3: Solving simple games

LicenseMIT
MaintainerJoe Leslie-Hurd <joe@gilith.com>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Solve.Game

Description

 

Documentation

data Player Source #

Constructors

Player1 
Player2 
Instances
Bounded Player Source # 
Instance details

Defined in Solve.Game

Enum Player Source # 
Instance details

Defined in Solve.Game

Eq Player Source # 
Instance details

Defined in Solve.Game

Methods

(==) :: Player -> Player -> Bool #

(/=) :: Player -> Player -> Bool #

Ord Player Source # 
Instance details

Defined in Solve.Game

Show Player Source # 
Instance details

Defined in Solve.Game

newtype PlayerState s Source #

Constructors

PlayerState (s, s) 

updatePlayerState :: (s -> (a, s)) -> PlayerState s -> Player -> (a, PlayerState s) Source #

type Moves = Int Source #

data Event Source #

Constructors

In Moves 
Never 
Instances
Eq Event Source # 
Instance details

Defined in Solve.Game

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Ord Event Source # 
Instance details

Defined in Solve.Game

Methods

compare :: Event -> Event -> Ordering #

(<) :: Event -> Event -> Bool #

(<=) :: Event -> Event -> Bool #

(>) :: Event -> Event -> Bool #

(>=) :: Event -> Event -> Bool #

max :: Event -> Event -> Event #

min :: Event -> Event -> Event #

Show Event Source # 
Instance details

Defined in Solve.Game

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

data Eval Source #

Constructors

Win Player Moves 
Draw 
Instances
Eq Eval Source # 
Instance details

Defined in Solve.Game

Methods

(==) :: Eval -> Eval -> Bool #

(/=) :: Eval -> Eval -> Bool #

Ord Eval Source # 
Instance details

Defined in Solve.Game

Methods

compare :: Eval -> Eval -> Ordering #

(<) :: Eval -> Eval -> Bool #

(<=) :: Eval -> Eval -> Bool #

(>) :: Eval -> Eval -> Bool #

(>=) :: Eval -> Eval -> Bool #

max :: Eval -> Eval -> Eval #

min :: Eval -> Eval -> Eval #

Show Eval Source # 
Instance details

Defined in Solve.Game

Methods

showsPrec :: Int -> Eval -> ShowS #

show :: Eval -> String #

showList :: [Eval] -> ShowS #

type Game p = Player -> p -> Either Eval [p] Source #

move :: Game p -> Player -> p -> [p] Source #

gameOver :: Game p -> Player -> p -> Bool Source #

type DfsPre p a v = Player -> DfsPre p a v Source #

type DfsPost p a v = Player -> DfsPost p a v Source #

type Val p v = DfsResult (Player, p) v Source #

dfsWith :: Ord p => DfsPre p a v -> DfsPost p a v -> Val p v -> Player -> p -> (v, Val p v) Source #

eval :: Ord p => Val p v -> Player -> p -> Maybe v Source #

evalUnsafe :: Ord p => Val p v -> Player -> p -> v Source #

bfs :: Ord p => Game p -> Player -> p -> [(Player, p)] Source #

type Solve p = Val p Eval Source #

solveWith :: Ord p => Game p -> Solve p -> Player -> p -> (Eval, Solve p) Source #

solve :: Ord p => Game p -> Player -> p -> Solve p Source #

perfectPlay :: Ord p => Game p -> Solve p -> Player -> p -> [(Player, p)] Source #

type Games p = Val p Integer Source #

gamesWith :: Ord p => Game p -> Games p -> Player -> p -> (Integer, Games p) Source #

games :: Ord p => Game p -> Player -> p -> Games p Source #

type Force p = Val p Event Source #

forceWith :: Ord p => Game p -> Player -> (Player -> p -> Bool) -> Force p -> Player -> p -> (Event, Force p) Source #

force :: Ord p => Game p -> Player -> (Player -> p -> Bool) -> Player -> p -> Force p Source #

data Max v Source #

Constructors

Max v Moves 
Instances
Eq v => Eq (Max v) Source # 
Instance details

Defined in Solve.Game

Methods

(==) :: Max v -> Max v -> Bool #

(/=) :: Max v -> Max v -> Bool #

Ord v => Ord (Max v) Source # 
Instance details

Defined in Solve.Game

Methods

compare :: Max v -> Max v -> Ordering #

(<) :: Max v -> Max v -> Bool #

(<=) :: Max v -> Max v -> Bool #

(>) :: Max v -> Max v -> Bool #

(>=) :: Max v -> Max v -> Bool #

max :: Max v -> Max v -> Max v #

min :: Max v -> Max v -> Max v #

Show v => Show (Max v) Source # 
Instance details

Defined in Solve.Game

Methods

showsPrec :: Int -> Max v -> ShowS #

show :: Max v -> String #

showList :: [Max v] -> ShowS #

gameMaxWith :: (Ord p, Ord v) => Game p -> Player -> (Player -> p -> v) -> Val p (Max v) -> Player -> p -> (Max v, Val p (Max v)) Source #

gameMax :: (Ord p, Ord v) => Game p -> Player -> (Player -> p -> v) -> Player -> p -> Val p (Max v) Source #

type Study p = (Player, Val p Int) Source #

studyWith :: Ord p => Game p -> Solve p -> Study p -> Player -> p -> (Int, Study p) Source #

study :: Ord p => Game p -> Solve p -> Player -> Player -> p -> Study p Source #

criticalPath :: Ord p => Game p -> Study p -> Player -> p -> [(Player, p)] Source #