This code solves the mastermind game.
I was given a mastermind game for Christmas and thought it woud be fun to write a program to solve it.
The initial plan was to use Knuth's 1977 algorithm. However, it turns out that algorithm is specific to a game with six (potentially repeated) colors, four potential positions, and repeated colors. That doesn't work for my game, which has six colors and five positions.
The minimax algorithm described by Knuth might still be interesting, but I don't fully understand it yet.
[watch this space]
- Tweaks for game setup
- Add error handling for duplicate colors in the list / too many positions
- Add posibility to randomly select solution
- Add possiblity to randomly select guess
- Add recording for games and plays (at least the number of turns)
- Implement a minimax algorithm for selecting the next guess (instead of randomly from the remaining set)