packages feed

hanabi-dealer-0.3.0.0: examples/SimpleStrategy.hs

{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module SimpleStrategy where
import Game.Hanabi hiding (main)
import System.Random

-- An example of a simple and stupid strategy.
data Simple = S ()

instance Monad m => Strategy Simple m where
  strategyName ms = return "Simple"
  move (pv:_) _mvs s = let pub = publicView pv
                           numHand = length $ head $ givenHints pub
                           mov | hintTokens pub == 8 = Play 0           -- Play the newest card if there are the max number of hint tokens.
                               | otherwise           = Drop (numHand-1) -- Otherwise, drop the oldest card.
                       in return (mov, s)

main = do g <- newStdGen
          ((eg,_),_) <- start defaultGS ([S ()],[stdio]) g -- Play it with standard I/O (human player).
          putStrLn $ prettyEndGame eg