Kevin E. Acevedo Jetter

Mastermind Game and Solver


mastermind game example

Implemented the board game of Mastermind and will create a solver which uses the Five-guess algorithm. The algorithm will always win the game in at most 5 turns.

Once the game begins, you should take the first guess.

To guess, write the first letter of the color you would like to guess. The six colors are the following: red r, blue b, yellow y, green g, orange o, and purple p. A guess consist of four colors, which could be repeated, separated by a space. Examples: r b g y, r r b o, p p p p.

After the first guess, you will get a message with the amount of black key pegs and white key pegs in no specific order. A black key peg means that you got a color in the correct position and a white key peg means that you have a correct color but in the wrong position. This will be given as four strings b, w, and _ for black key peg, white key peg, and not a black key peg nor a white key peg, respectively.

This will continue until you get the correct combination or you have used all your guesses.

To play, run the file in the terminal: python3 main.py

The source code can be found here.