*Codebreaker* is the same as *Mastermind.* Digits are used instead of colours. The computer chooses a pattern of four digits. In the standard variant it uses digits 1-6. There are also alternative variants implemented that use up to 8 digits. Duplicates are allowed, so the computer could even choose the same four code digits. The chosen pattern is placed upmost but hidden to the player. This game can also be played by two players with pen and paper.

The codebreaker tries to guess the pattern, in both order and correct digit, within nine turns. Each guess is made by placing a row of code digits on the decoding board. Once placed, the program provides feedback by placing from zero to four key pegs at the sideboard. A black key peg is placed for each code digit from the guess which is correct in both digit and position; a white peg indicates that a correct digit is placed in the wrong position. The black pegs are always placed leftmost, so there is no correlation of position. Once feedback is provided, another guess is made; guesses and feedback continue to alternate until either the codebreaker guesses correctly, or nine incorrect guesses are made. If you can keep an average of five or below in the standard variant, then you are good. An inexperienced player can begin at the easiest level where only digits 1-4 are used in the code.

Mastermind or Master Mind is a simple code-breaking board game for two players, invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. A similar pencil and paper game, called bulls and cows, was played at least as far back as the early 1960’s. With 4 positions and 6 digits, there are 6^{4} = 1296 different patterns. In 1977, Donald Knuth demonstrated that an algoritm can solve the pattern in five moves or fewer, using an algorithm that progressively reduces the number of possible patterns (Wikipedia). See also Expert Codebreaker, here.

☛ You can download my free Codebreaker program here (updated 2017-05-31), but you must own the software Zillions of Games to be able to run it. (I recommend the download version.)

© Mats Winther 2008