deterministic-game-engine (empty) → 0.1.0.0
raw patch · 5 files changed
+95/−0 lines, 5 filesdep +basedep +deterministic-game-enginedep +hspecsetup-changed
Dependencies added: base, deterministic-game-engine, hspec
Files
- LICENSE +1/−0
- Setup.hs +2/−0
- Spec/Spec.hs +1/−0
- Src/GameEngine.hs +50/−0
- deterministic-game-engine.cabal +41/−0
+ LICENSE view
@@ -0,0 +1,1 @@+MIT License, Man. Have at it.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Spec/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
+ Src/GameEngine.hs view
@@ -0,0 +1,50 @@+module GameEngine (+ Symbol,+ GameState(..),+ Player(..),+ Move(..),+ GameActions(..),+ GameEngine(..),+ play+ ) where+++type Symbol = Char+++data GameState a = GameState a+++data Player = Player Char+++data Move a = Move a+++data GameActions a b = GameActions {+ getPlayer :: GameState a -> Player,+ getMoves :: GameState a -> [Move b],+ getResult :: GameState a -> Move b -> GameState a,+ isTerminal :: GameState a -> Bool,+ getScore :: GameState a -> Player -> Int+ }+++data GameEngine a b = GameEngine {+ gameActions :: GameActions a b,+ state :: GameState a+ }+++play :: GameEngine a b -> Int+play engine+ | performWithState isTerminal engine = performWithState getScore engine $ performWithState getPlayer engine+ | otherwise = play $ GameEngine (gameActions engine) (getNextState engine)+++getNextState :: GameEngine a b -> GameState a+getNextState engine = performWithState getResult engine . head $ performWithState getMoves engine+++performWithState :: (GameActions a b -> GameState a -> c) -> GameEngine a b -> c+performWithState f engine = f (gameActions engine) $ state engine
+ deterministic-game-engine.cabal view
@@ -0,0 +1,41 @@+-- Initial deterministic-game-engine.cabal generated by cabal init. For+-- further documentation, see http://haskell.org/cabal/users-guide/++name: deterministic-game-engine+version: 0.1.0.0+synopsis: Simple deterministic game engine+description: Game engine for creating deterministic games.+license: MIT+license-file: LICENSE+author: Tyler Olson+maintainer: tydotg@gmail.com+homepage: https://github.com/TGOlson/deterministic-game-engine+bug-reports: https://github.com/TGOlson/deterministic-game-engine/issues+-- copyright:+category: Game Engine+build-type: Simple+-- extra-source-files:+cabal-version: >=1.10++Source-repository head+ Type: git+ Location: https://github.com/TGOlson/deterministic-game-engine+++library+ hs-source-dirs: Src+ exposed-modules: GameEngine++ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.0 && <5.0+ default-language: Haskell2010++test-suite test+ hs-source-dirs: Spec+ main-is: Spec.hs+ ghc-options: -Wall+ type: exitcode-stdio-1.0+ build-depends: base >=4.0 && <5.0,+ hspec >=2.1 && <2.2,+ deterministic-game-engine