“Mastermind” is a reasoning board game much like Bulls and Cows (called Hit & Blow in Japan). Its name is said to be a trademark, so here we only introduce how the game is played, as far as we can confirm.
What kind of game is it?
It is a two-player board game said to have been invented around 1970 (for how number-guessing games changed over time, see The History of Number-Guessing Games).
- One player lines up some colored pegs and hides them as the answer.
- The other player lines up colored pegs as a guess.
- The player who hid the answer gives back the clue with small pegs. In the best-known way to play, small pegs of different colors show the number of pegs with the right color in the right place and the number of pegs with the right color in the wrong place.
The clues mean the same thing as hits and blows in Bulls and Cows.
The biggest difference: colors can repeat
In the best-known way to play, the answer can use the same color as many times as you like. In Bulls and Cows, the answer and the guesses use all-different symbols.
Letting colors repeat changes the number of candidates. For example, when you line up 4 pegs from 6 colors,
- If the same color can repeat: 6 × 6 × 6 × 6 = 1296 ways
- If the same color cannot repeat: 6 × 5 × 4 × 3 = 360 ways
When colors repeat, you also need to be careful about how to count “right color in the wrong place.” Compare how many of each color are in the answer and in the guess, and count only the smaller number.
With 6 colors and 4 pegs, 5 guesses are enough
For 4 pegs from 6 colors (colors can repeat), we checked all 1296 answers and calculated the number of guesses for the strategy. For each guess, it splits the candidates by the possible clues and picks the row that makes the biggest leftover group smallest (the first guess starts with “two of one color plus two of another color”).
| Guesses | Number of answers |
|---|---|
| 1 guess | 1 |
| 2 guesses | 6 |
| 3 guesses | 62 |
| 4 guesses | 533 |
| 5 guesses | 694 |
Any answer can be solved in 5 guesses or fewer, with an average of about 4.48. This strategy and result are known as work shown by the computer scientist Donald Knuth in the 1970s.
Compared with Bulls and Cows
| Game | Symbols | Candidates |
|---|---|---|
| Mastermind (6 colors, 4 pegs) | The same color can repeat | 1296 |
| Bulls and Cows, 3 digits | All different | 720 |
| Bulls and Cows, 4 digits | All different | 5040 |
With 4 digits, Bulls and Cows has many candidates, 5040, and by calculation any answer can be solved in 7 guesses or fewer (the average is about 5.3, depending on the strategy) (Is There a Winning Strategy for Bulls and Cows?).
Bulls and Cows with colors
The rule in the app “Bulls and Cows” is “all-different symbols,” but you can change how the symbols look by dressing them up. With the color balls or gem symbol sets, it feels like guessing a row of colors. The color balls are made so that people who see colors differently can still tell them apart by their patterns (Playing with Symbols Other Than Numbers).
