pig-0.0.1: dice game

Safe HaskellSafe
LanguageHaskell98

Pig

Description

Pig simulates a dice game.

Synopsis

Documentation

roll :: IO Int Source #

roll simulates a six-sided die.

data Move Source #

Move models valid game actions.

Constructors

Roll 
Hold 

type Strategy = [Player] -> [Int] -> Move Source #

Strategy models player tactics.

data Player Source #

Player models information available to combatants.

Constructors

Player 

Fields

sayN :: Int -> Int -> String -> String -> IO () Source #

sayN provides a debugging hook during development.

play :: [Player] -> Int -> [Int] -> IO Player Source #

play executes a game of Pig and returns the winner.

alwaysHold :: Strategy Source #

alwaysHold models a simple player who always holds.

alwaysRoll :: Strategy Source #

alwaysRoll models a simple player who always rolls.

hundredOrBust :: Strategy Source #

hundredOrBust models a player who strives for 100 points.

rollOnce :: Strategy Source #

rollOnce models a player who rolls only once.

roll5 :: Strategy Source #

roll5 models a player who rolls up to five times.

roll6 :: Strategy Source #

roll6 models a player who rolls up to six times.

rollK :: Strategy Source #

rollK rolls to keep up with the current top player.

rollBadK :: Strategy Source #

rollBadK is a poor player

defaultPlayer :: Player Source #

defaultPlayer constructs a new player.

ah :: Player Source #

ah always holds.

ar :: Player Source #

ar always rolls.

hob :: Player Source #

hob busts at 100.

ro :: Player Source #

ro rolls once.

r5 :: Player Source #

r5 rolls five times.

r6 :: Player Source #

r6 rolls six times.

rk :: Player Source #

rk rolls to keep up with the top player.

rb :: Player Source #

rb is a bad player.

test :: [Player] -> IO Player Source #

test executes multiple games.

track :: [Player] -> Map String Int -> Map String Int Source #

track records player wins across games.

stats :: [Player] -> [(String, Int)] Source #

stats sorts game scores.

addLosers :: [Player] -> [(String, Int)] -> [(String, Int)] Source #

addLosers identifies consistently low-scoring strategies.