Skip to content

lauraDascalu/Mastermind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Mastermind in Haskell (Five-Guess Algorithm)

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.

Game Overview

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

Features

  • 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 randomly
    • player: uses Knuth’s Five-Guess strategy with minimax pruning

Code Logic

  • 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors