Robson » Little Red Book » Mastermind

Chapter 9 - Question 9

Games of logical deduction are an obvious choice for programming. The prime example is the code breaking game of mastermind.

It is fairly easy to program the computer to act as a code maker, with a user trying to find the computer's code. More difficult is to program the computer to find the user's code.

Solution 1

This question is split into two. The first is to write a mastermind game where the computer has the sequence and the user guesses, the second is where the computer attempts to work out the sequence. I feel the first is the more interesting solution, so I've started with that one.

View the Mastermind code or play some mastermind?


© 2004-17 robson | cc unless stated