-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Solving simple games -- -- A library for solving and analyzing finite two-player games (e.g., Fox -- & Hounds). @package solve @version 1.1 module Solve.Util parity :: [Bool] -> Bool singleton :: a -> [a] doubleton :: a -> a -> [a] tripleton :: a -> a -> a -> [a] mapLR :: (s -> a -> (b, s)) -> s -> [a] -> ([b], s) mapRL :: (a -> s -> (s, b)) -> [a] -> s -> (s, [b]) unfold :: (a -> (b, a)) -> a -> [b] unfoldN :: (a -> (b, a)) -> Int -> a -> ([b], a) updateSet :: Ord a => (a -> [a]) -> Set a -> [Set a] transitiveClosure :: Ord a => (a -> [a]) -> [a] -> Set a type Prob = Double normalize :: [Double] -> [Prob] expectation :: [Prob] -> [Double] -> Double isZeroProb :: Prob -> Bool nonZeroProb :: Prob -> Bool boolProb :: Bool -> Prob showProb :: Prob -> String showTable :: [[String]] -> String module Solve.Graph type DfsPre n a v = n -> Either v [(a, n)] type DfsPost n a v = n -> [((a, n), Maybe v)] -> v type DfsResult n v = Map n v dfsWith :: Ord n => DfsPre n a v -> DfsPost n a v -> DfsResult n v -> n -> (v, DfsResult n v) dfs :: Ord n => DfsPre n a v -> DfsPost n a v -> n -> (v, DfsResult n v) eval :: Ord n => DfsResult n v -> n -> Maybe v evalUnsafe :: Ord n => DfsResult n v -> n -> v module Solve.Game data Player Player1 :: Player Player2 :: Player newtype PlayerState s PlayerState :: (s, s) -> PlayerState s turn :: Player -> Player getPlayerState :: PlayerState s -> Player -> s updatePlayerState :: (s -> (a, s)) -> PlayerState s -> Player -> (a, PlayerState s) data Eval Win :: Player -> Int -> Eval Draw :: Eval better :: Ord a => Player -> a -> a -> Bool best :: Ord a => Player -> [a] -> a betterEval :: Player -> Eval -> Eval -> Bool sameEval :: Eval -> Eval -> Bool winning :: Player -> Eval -> Bool win :: Player -> Eval delay :: Eval -> Eval turnEval :: Eval -> Eval type Game p = Player -> p -> Either Eval [p] move :: Game p -> Player -> p -> [p] type DfsPre p a v = Player -> DfsPre p a v type DfsPost p a v = Player -> DfsPost p a v type Val p v = DfsResult (Player, p) v dfsWith :: Ord p => DfsPre p a v -> DfsPost p a v -> Val p v -> Player -> p -> (v, Val p v) eval :: Ord p => Val p v -> Player -> p -> Maybe v evalUnsafe :: Ord p => Val p v -> Player -> p -> v type Solve p = Val p Eval solveWith :: Ord p => Game p -> Solve p -> Player -> p -> (Eval, Solve p) solve :: Ord p => Game p -> Player -> p -> Solve p reachable :: Solve p -> Int data Force ForceIn :: Int -> Force ForceNever :: Force type Forced p = Val p Force bestForce :: Ord a => Player -> Player -> [a] -> a delayForce :: Force -> Force forcedWith :: Ord p => Game p -> Player -> (Player -> p -> Bool) -> Forced p -> Player -> p -> (Force, Forced p) forced :: Ord p => Game p -> Player -> (Player -> p -> Bool) -> Player -> p -> Forced p data Max v Max :: v -> Int -> Max v gameMaxWith :: (Ord p, Ord v) => Game p -> Player -> (Player -> p -> v) -> Val p (Max v) -> Player -> p -> (Max v, Val p (Max v)) gameMax :: (Ord p, Ord v) => Game p -> Player -> (Player -> p -> v) -> Player -> p -> Val p (Max v) type Weight = Double type Strategy p = [(Weight, p)] -> [(Weight, p)] moveDistStrategy :: Eq p => Game p -> Strategy p -> Player -> p -> [(Prob, p)] distStrategy :: Eq p => Strategy p -> [p] -> [(Prob, p)] applyStrategy :: Strategy p -> [p] -> [(Weight, p)] weightlessStrategy :: [p] -> [(Weight, p)] idStrategy :: Strategy p noStrategy :: Strategy p thenStrategy :: Strategy p -> Strategy p -> Strategy p orelseStrategy :: Strategy p -> Strategy p -> Strategy p tryStrategy :: Strategy p -> Strategy p filterStrategy :: (p -> Bool) -> Strategy p sameEvalStrategy :: Eval -> (p -> Eval) -> Strategy p maxStrategy :: Ord v => (p -> v) -> Strategy p bestStrategy :: Player -> (p -> Eval) -> Strategy p stopLossStrategy :: Ord p => Solve p -> Player -> Int -> Strategy p forcedStrategy :: Ord p => Forced p -> Player -> Int -> Strategy p type StrategyFail p = Set ((Eval, p), (Eval, p), (Eval, p)) validateStrategy :: Ord p => Game p -> Solve p -> Player -> Strategy p -> Player -> p -> StrategyFail p type ProbWin p = Val p Prob type Adversaries p = PlayerState [(Strategy p, ProbWin p)] probWinWith :: Ord p => Game p -> Player -> Strategy p -> ProbWin p -> Player -> p -> (Prob, ProbWin p) probWin :: Ord p => Game p -> Player -> Strategy p -> Player -> p -> ProbWin p moveDist :: Ord p => Game p -> Solve p -> Adversaries p -> Player -> p -> ([(Prob, p)], Adversaries p) instance GHC.Classes.Eq v => GHC.Classes.Eq (Solve.Game.Max v) instance GHC.Show.Show v => GHC.Show.Show (Solve.Game.Max v) instance GHC.Show.Show Solve.Game.Force instance GHC.Classes.Ord Solve.Game.Force instance GHC.Classes.Eq Solve.Game.Force instance GHC.Show.Show Solve.Game.Eval instance GHC.Classes.Eq Solve.Game.Eval instance GHC.Show.Show Solve.Game.Player instance GHC.Classes.Ord Solve.Game.Player instance GHC.Classes.Eq Solve.Game.Player instance GHC.Classes.Ord v => GHC.Classes.Ord (Solve.Game.Max v) instance GHC.Classes.Ord Solve.Game.Eval module Solve.FoxHounds packSize :: Int boardSize :: Int numSquares :: Int type Idx = Int data Coord Coord :: Int -> Int -> Coord onBoard :: Coord -> Bool rankAdjacent :: Int -> Int -> [Coord] foxAdjacent :: Coord -> [Coord] houndAdjacent :: Coord -> [Coord] houndsReachable :: Set Coord -> Set Coord foxReachable :: Set Coord -> Coord -> Set Coord coordParity :: Coord -> Bool coordToSquare :: Coord -> Idx squareToCoord :: Idx -> Coord data Pos Pos :: Coord -> Set Coord -> Pos [fox] :: Pos -> Coord [hounds] :: Pos -> Set Coord initial :: Pos occupied :: Pos -> Coord -> Bool empty :: Pos -> Coord -> Bool foxBox :: Pos -> Bool posParity :: Pos -> Bool posToMove :: Pos -> Player posToIdx :: Pos -> Idx idxToPos :: Idx -> Pos foxMove :: Pos -> [Pos] houndsMove :: Pos -> [Pos] move :: Player -> Pos -> [Pos] foxEscaped :: Pos -> Bool won :: Player -> Pos -> Maybe Player game :: Game Pos evalInitial :: Val Pos v -> v solution :: Solve Pos winningFor :: Player -> Player -> Pos -> Bool winningForFox :: Player -> Pos -> Bool winningForHounds :: Player -> Pos -> Bool winDepth :: Player -> Pos -> Int forcedFoxBox :: Forced Pos maxForcedFoxBox :: Val Pos (Max Force) stopLossStrategy :: Player -> Int -> Strategy Pos foxBoxStrategy :: Int -> Strategy Pos maxFoxBoxStrategy :: Player -> Strategy Pos foxStrategy :: Int -> Strategy Pos houndsStrategy :: Int -> Strategy Pos adversaries :: Adversaries Pos strategy :: Player -> Pos -> Strategy Pos moveDist :: Player -> Pos -> [(Prob, Pos)] validateStrategy :: Player -> Strategy Pos -> StrategyFail Pos probWin :: Player -> Strategy Pos -> ProbWin Pos ppPlayer :: Player -> String ppEval :: Eval -> String instance GHC.Classes.Ord Solve.FoxHounds.Pos instance GHC.Classes.Eq Solve.FoxHounds.Pos instance GHC.Classes.Ord Solve.FoxHounds.Coord instance GHC.Classes.Eq Solve.FoxHounds.Coord instance GHC.Show.Show Solve.FoxHounds.Pos instance GHC.Show.Show Solve.FoxHounds.Coord