"Mastermind" is a widely played board game involving two players. One player creates a hidden pattern on one side of a board, while the other attempts to solve it within a limited amount of turns. The classic version uses six different colours, a pattern made from four colours, and the player has 12 attempts to solve the pattern. Several strategies revolve around solving the pattern in the fewest amount of turns.
Game Basics: Deduction
Playing "Mastermind" is essentially juggling several "if, then" statements. It is fundamental to know the meaning of the responses of the codemaker. For example, if he responds with four white pegs, that means you have four possible orders to use four colours. If he responds with two red pegs on two separate occasions, you have to determine which colour and placing is most likely correct between your two attempts.
A way to ease players into "Mastermind" is to use only single changes between guesses. This means that except for changing the placement or colour of a pin, the subsequent guess remains exactly the same as the previous one. For example, a first guess may use four red pins. Based on the codemaker's response, you could change one pin to yellow and keep all other pins red for the next round. This is a good way to train yourself in deduction. It is also a viable strategy depending on the codemaker's initial answer.
Importance of Pegs
A basic rule of "Mastermind" is that a red peg takes precedence over a white one; this means that a red peg usually replaces a previous white peg. This fact will narrow down the possible patterns considerably because there are fewer correct answers left. Additionally, the absence of a peg also indicates that a colour is not used at all. One missing peg can eliminate one-sixth of all possible combinations at the most.
Math: First Moves
Jorg Bewersdorff, author of "Luck, Logic and White Lies: the Mathematics of Games", studied Donald E. Knuth's claim of the best possible opening move in "Mastermind." Knuth's optimal worse case strategy is to use two colours, side-by-side, as the opening move: for example, white, white, yellow, yellow. In the worst case scenario, the number of possible codes remaining is reduced from 32,768 to 256. Assuming do not make any logic mistakes, this strategy will allow you to statistically guess any code within six tries. R.W. Irving, a Vietnamese statistician, believed using three colours reduced the possible codes even further than Knuth's worse case strategy. For example, using white, white, red and teal allowed the user to guess the code in an average of 4.369 tries compared to Knuth's 4.478.