board-games-0.2: Three games for inclusion in a web server

Safe HaskellSafe
LanguageHaskell2010

Game.Mastermind

Synopsis

Documentation

data Eval Source #

Constructors

Eval Int Int 
Instances
Eq Eval Source # 
Instance details

Defined in Game.Mastermind

Methods

(==) :: Eval -> Eval -> Bool #

(/=) :: Eval -> Eval -> Bool #

Ord Eval Source # 
Instance details

Defined in Game.Mastermind

Methods

compare :: Eval -> Eval -> Ordering #

(<) :: Eval -> Eval -> Bool #

(<=) :: Eval -> Eval -> Bool #

(>) :: Eval -> Eval -> Bool #

(>=) :: Eval -> Eval -> Bool #

max :: Eval -> Eval -> Eval #

min :: Eval -> Eval -> Eval #

Show Eval Source # 
Instance details

Defined in Game.Mastermind

Methods

showsPrec :: Int -> Eval -> ShowS #

show :: Eval -> String #

showList :: [Eval] -> ShowS #

evaluate :: Ord a => [a] -> [a] -> Eval Source #

Given the code and a guess, compute the evaluation.

matching :: (C set, Ord a) => Set a -> [a] -> Eval -> set a Source #

Given a code and an according evaluation, compute the set of possible codes.

The Game.Mastermind game consists of collecting pairs of codes and their evaluations. The searched code is in the intersection of all corresponding code sets.

matchingSimple :: Ord a => Set a -> [a] -> Int -> [[Set a]] Source #

A variant of the game: It is only possible to specify number of symbols at right places.

The results of matching and matchingSimple cannot be compared.

mixedRandomizedAttempt :: (C set, RandomGen g, Ord a) => Int -> set a -> StateT g Maybe [a] Source #

In the beginning we simply choose a random code from the set of possible codes. In the end, when the set becomes small, then we compare different alternatives.

partitionSizes :: Ord a => Set a -> [a] -> [(Eval, Integer)] Source #

mainSimple :: T Char -> Int -> IO () Source #

mainRandom :: T Char -> Int -> IO () Source #

main :: IO () Source #

propBestSeparatingCode :: (C set, Ord a) => Int -> set a -> [[a]] -> Bool Source #