0

## MastermindTM

Published on Thursday, December 13, 2007 in , , , , ,

Since it's the holiday season, I've been turned my attention classics and toys. One of the classics that used to puzzle me in my youth was the classic game of MastermindTM.

This is the classic two-person game in which one person sets up a code consisting of four colored pegs, chosen from among 6 different colors. Since repeating colors in the code is allowed, this means that the code could be any one of 1,296 (6 * 6 * 6 * 6) possibilities. The other player has 10 guesses to figure out the code. The only clues this player gets from the person who set up the code is in the form of black and white "clue pegs". For every correct color the guesser has in the correct spot, they are given 1 black clue peg. For every correct color the guesser has in the wrong spot, they are given 1 white clue peg.

Interpreting the clues from your current guess, combined with the clues provided in earlier guesses, becomes an exercise in logic. What colors are always in my correct guesses, and which colors aren't?

If you would like to put your mind up against this test, I've added it to the site! In the Mental Gym, you can now find a Java version of MastermindTM (In this version, you only have 8 guesses). If you would prefer to play it on your iPhone or iPod Touch, I've added a link to the game SuperBrain (opens in new window) to the iPhone Mental Gym.

If you prefer the real board game, perhaps as a gift, I've also added the MastermindTM Travel Attache set to the Recommended Products Store.

Once you've tried it out in one form or another, you're probably asking yourself, is it really possible to narrow the code down from 1,296 possibilities in only 10 guesses, even with the clues you get? Believe it or not, not only is it possible, but when played correctly, you will never need more than 5 guesses to break the code!

In the earlier MastermindTM Wikipedia entry, there is a brief discussion of the five guess algorithm. If you would like to learn more about it, Toby Nelson's Investigations into the MastermindTM Board Game is an excellent resource. It describes the mathematical basics of the game, and then goes into the hows and whys of the algorithm itself. Fortunately, this is all done in clear language, and is easy to follow. Once you understand the basic ideas, Mr. Nelson even provides a strategy table, showing how every code can be resolved in 5 moves or less.

My suggestion is not to peek at this approach, but try playing the game first. See if you can arrive at some of your own strategies before looking at the algorithms. Good luck and happy decoding!