Mastermind is a board game where player A create a code of a number of symbols (colors, digits, letters) and player B has to guess the code. Player A evaluates every guess of the code using black pegs, meaning "right symbol at right place", and white pegs, meaning "right symbol at wrong place". Player B has to reconstruct the code using only these evaluations.
It is a nice task to let the computer guess a code. Here are some solutions in Haskell:
- board-games: Uses an explicit representation of the set of all codes that match a certain evaluation.
- set-cover: Uses an exact set cover formulation of the property that a code matches an evaluation.
- https://github.com/danielX/mastermind-haskell: Brute-force check of whether a code matches evaluations.
There are also implementations focussing on the game player rather than a computer player:
- Wikipedia on Mastermind