-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple deterministic game engine -- @package deterministic-game-engine @version 0.3.0 -- | Haskell library for creating simple deterministic games, such as -- tic-tac-toe. The engine requires a minimal set of actions related to -- the game, and then will run the game until a terminal state is -- reached. -- -- Simple generic example below. See the specs for a more detailed -- example. -- --
--   import GameEngine
--   
--   game :: GameEngine Int Int
--   game = GameEngine gameActions initialState
--   
--   gameActions :: GameActions Int Int
--   gameActions = GameActions {
--      getPlayer  = -- find the next player from a game state,
--      getMove    = -- find a move from the game state,
--      getResult  = -- transitions from a state to another state,
--      isTerminal = -- determines if the game is terminal,
--      getScore   = -- get score from a terminal state
--    }
--   
--   initialState :: GameState Int
--   initialState = GameState 0
--   
--   -- run the game engine until a terminal state is reached
--   playSimple game
--   
module Game.Deterministic.GameEngine type Symbol = Char data GameState a GameState :: a -> GameState a data Player Player :: Symbol -> Player data Move a Move :: a -> Move a -- | Set of actions that defines how the game will be played data GameActions m a b GameActions :: (GameState a -> m Player) -> (GameState a -> m (Move b)) -> (GameState a -> Move b -> m (GameState a)) -> (GameState a -> m Bool) -> (GameState a -> Player -> m Int) -> GameActions m a b -- | Specifies which player has the move in the state getPlayer :: GameActions m a b -> GameState a -> m Player -- | Returns a legal move in the state getMove :: GameActions m a b -> GameState a -> m (Move b) -- | The transition model, which determines the result of a move getResult :: GameActions m a b -> GameState a -> Move b -> m (GameState a) -- | True if game is over, False otherwise isTerminal :: GameActions m a b -> GameState a -> m Bool -- | A utility function to determine the numeric value for a game that ends -- in a terminal state getScore :: GameActions m a b -> GameState a -> Player -> m Int -- | Holds information about how the game is played, and the current state -- of the game. data GameEngine m a b GameEngine :: GameActions m a b -> GameState a -> GameEngine m a b -- | Defines how the game will be played actions :: GameEngine m a b -> GameActions m a b -- | The current state of the game state :: GameEngine m a b -> GameState a type GameEngineSimple a b = GameEngine Identity a b type GameEngineIO a b = GameEngine IO a b -- | Run the provided game engine under a monadic context until a terminal -- state is reached. play :: Monad m => GameEngine m a b -> m Int -- | Run the provided game engine without a context until a terminal state -- is reached. playSimple :: GameEngineSimple a b -> Int -- | Run the provided game engine within an IO context until a terminal -- state is reached. playIO :: GameEngineIO a b -> IO Int