Mastermind (board game)

Mastermind or Master Mind (Hebrew: בול פגיעה, romanized: bul pgi'a) is a code-breaking game for two players invented in Israel. It resembles an earlier pencil and paper game called Bulls and Cows that may date back a century.
Mastermind was invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. After presenting the idea to major toy companies and showing it at the Nuremberg International Toy Fair, it was picked up by a plastics company, Invicta Plastics, based near Leicester, UK. Invicta purchased all the rights to the game, and the founder, Edward Jones-Fenleigh, refined the game further. It was released in 1971–2.
The game is based on a paper and pencil game called Bulls and Cows. A computer adaptation was run in the 1960s on Cambridge University’s Titan computer system, where it was called 'MOO'. This version was written by Frank King. Other versions were written for the TSS/8 time sharing system by J.S. Felton, for Unix by Ken Thompson, and for the Multics system at MIT by Jerrold Grochow.
Since 1971, the rights to Mastermind have been held by Invicta Plastics. (Invicta always called the game Master Mind.) They originally manufactured it themselves, though they have since licensed its manufacture to Hasbro worldwide, with the exception of Pressman Toys and Orda Industries who have the manufacturing rights to the United States and Israel, respectively. Chieftain Products acquired the rights to manufacture in Canada in 1972, though they went out of business in 1996.
Starting in 1973, the game box featured a photograph of a man in a suit jacket seated in the foreground, with a young woman standing behind him. The two amateur models (Bill Woodward and Cecilia Fung) reunited in June 2003 to pose for another publicity photo.
The game is played using:
The two players decide in advance how many games they will play, which must be an even number. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. Players decide in advance whether duplicates and blanks are allowed. If so, the codemaker may choose up to four same-colored code pegs or four blanks. If blanks are not allowed in the code, the codebreaker may not use blanks in their guesses. The codemaker places the chosen pattern in the four holes covered by the shield, visible to the codemaker but not to the codebreaker.
The codebreaker tries to deduce the pattern, in both order and color, within eight to twelve turns. Each attempt is made by placing a row of code pegs on the decoding board. Once placed, the codemaker provides feedback by placing from zero to four key pegs in the small holes of the row with the guess. A colored key peg is placed for each code peg from the guess which is correct in both color and position. A white key peg indicates a code peg that belongs in the solution, but is incorrectly positioned.
If there are duplicate colors in the guess, they cannot all be awarded a key peg unless they correspond to the same number of duplicate colors in the hidden code. For example, if the hidden code is red-red-blue-blue and the codebreaker places red-red-red-blue, the codemaker will award three colored key pegs for the first two reds and the blue, but nothing for the third red. No indication is given of the fact that the code also includes a second blue.
Once feedback is provided, another attempt is made; tests and feedback continue to alternate until either the codebreaker deduces correctly, or all rows on the decoding board are full.
Traditionally, players can only earn points when playing as the codemaker. The codemaker gets one point for each guess the codebreaker makes. An extra point is earned by the codemaker if the codebreaker is unable to deduce the exact pattern within the given number of turns. (An alternative is to score based on the number of key pegs placed.) The winner is the one who has the most points after the agreed-upon number of games are played.
Other rules may be specified.
Before asking for a best strategy of the codebreaker one has to define what is the meaning of "best": The minimal number of moves can be analyzed under the conditions of worst and average case and in the sense of a minimax value of a zero-sum game in game theory.
With four holes and six colors, there are 6 = 1,296 different patterns (allowing duplicate colors but not blanks).
In 1977, Donald Knuth demonstrated that the codebreaker can solve the pattern in five moves or fewer, using an algorithm that progressively reduces the number of possible patterns. Described using the numbers 1–6 to represent the six colors of the code pegs, the algorithm works as follows:
Subsequent mathematicians have been finding various algorithms that reduce the average number of turns needed to solve the pattern: in 1993, Kenji Koyama and Tony W. Lai performed an exhaustive depth-first search showing that the optimal method for solving a random code could achieve an average of 5,625/1,296 = 4.3403 turns to solve, with a worst-case scenario of six turns.
The minimax value in the sense of game theory is 5,600/1,290 = 4.3411. The minimax strategy of the codemaker consists in a uniformly distributed selection of one of the 1,290 patterns with two or more colors.
A new algorithm with an embedded genetic algorithm, where a large set of eligible codes is collected throughout the different generations. The quality of each of these codes is determined based on a comparison with a selection of elements of the eligible set. This algorithm is based on a heuristic that assigns a score to each eligible combination based on its probability of actually being the hidden combination. Since this combination is not known, the score is based on characteristics of the set of eligible solutions or the sample of them found by the evolutionary algorithm.
The algorithm works as follows, with P = length of the solution used in the game, X1 = exact matches ("red pins") and Y1 = near matches ("white pins"):
In November 2004, Michiel de Bondt proved that solving a Mastermind board is an NP-complete problem when played with n pegs per row and two colors, by showing how to represent any one-in-three 3SAT problem in it. He also showed the same for Consistent Mastermind (playing the game so that every guess is a candidate for the secret code that is consistent with the hints in the previous guesses).
The Mastermind satisfiability problem (MSP) is a decision problem that asks, "Given a set of guesses and the number of colored and white key pegs scored for each guess, is there at least one secret pattern that generates those exact scores?" (If not, then the codemaker must have incorrectly scored at least one guess.) In December 2005, Jeff Stuckman and Guo-Qiang Zhang showed in an arXiv article that MSP is NP-complete.
Varying the number of colors and the number of holes results in a spectrum of Mastermind games of different levels of difficulty. Another common variation is to support different numbers of players taking on the roles of codemaker and codebreaker. The following are some examples of Mastermind games produced by Invicta, Parker Brothers, Pressman, Hasbro, and other game manufacturers:
There was also a version called Super Code produced in East Germany by VEB Plasticart.
The difficulty level of any of the above can be increased by treating “empty” as an additional color or decreased by requiring only that the code's colors be guessed, independent of position. In Mini Mastermind the colored code pegs are the same size and shape as the colored or white key pegs so the difficulty can be increased by permitting the key pegs to be used as code pegs for two additional colors.
Computer and Internet versions of the game have also been made, sometimes with variations in the number and type of pieces involved and often under different names to avoid trademark infringement. Mastermind can also be played with paper and pencil. There is a numeral variety of the Mastermind in which a 4-digit number is guessed. The 2021 web game Wordle has been compared to Mastermind; however, in Wordle a response to a guess indicates which letters (corresponding to code pegs) are correctly placed or incorrectly placed, whereas in Mastermind only the count of correctly and incorrectly placed code pegs are indicated.
The game was included in the compilation party video game Clubhouse Games: 51 Worldwide Classics for the Nintendo Switch under the name "Hit & Blow".