This is a Haskell implementation of the classic board game Mastermind, featuring an automated player based on the Five-Guess Algorithm.
I referred to Cracking the Mastermind Code by Sylvester de Graaf (LIACS, 2019) for theoretical understanding. The Haskell implementation is independently written based on the core algorithmic concepts.
Mastermind is a code-breaking game where one player sets a secret combination of colored pegs and the other tries to guess the code. After each guess, feedback is given in terms of:
- Black Pegs: correct color in the correct position
- White Pegs: correct color in the wrong position
- Supports configurable code size (default: 4 pegs)
- Configurable set of colors (default: 5 colors)
- Generates a random secret code to be guessed
- Includes two AI players:
naive_player: chooses guesses randomlyplayer: uses Knuth’s Five-Guess strategy with minimax pruning
- The secret code is a list of colors randomly generated.
- Each guess receives feedback in terms of black and white pegs.
- The "AI" player;
- Starts with a fixed initial guess (
["blue", "blue", "red", "red"]) - Eliminates inconsistent guesses based on past feedback
- Uses the Minimax heuristic to select the next optimal guess
- Starts with a fixed initial guess (