How to Play Mastermind (Code Breaker)

Mastermind is a celebrated two-player deductive logic game invented in 1970 by Israeli postmaster and telecommunications expert Mordecai Meirowitz. In this single-player digital adaptation, the computer acts as the Codemaker, selecting a secret combination of 4 colored pegs chosen from 6 vivid hues. Your goal as the Codebreaker is to guess the exact sequence within 10 turns.

  1. Choose Colors: Select a color from the palette, then tap any of the four circular peg slots in the active row to place that color.
  2. Submit Guess: When all four slots in the row are filled, click Check Guess.
  3. Analyze Key Peg Clues: The game provides feedback in the small peg matrix to the right of your guess:
    • Red / Black Key Peg: Indicates one peg is the correct color in the exact correct position.
    • White Key Peg: Indicates one peg is the correct color, but placed in the wrong position.
    • Empty Hole: Indicates a peg that is completely absent from the secret code.
  4. Note on Key Peg Placement: The order of feedback pegs does not correspond to the order of your colored pegs. For example, a black peg on the left does not necessarily mean your first color is in the right position.
  5. Winning: If you receive four black key pegs, you have cracked the code! If you fail to deduce the combination within 10 rounds, the secret code is unveiled and the round ends.

Proven Strategies for Solving Mastermind

Cracking Mastermind consistently requires eliminating large swathes of possible permutations through information-theoretic testing. Relying on gut guesses will quickly exhaust your 10 rows. Master these fundamental principles:

1. Begin with Symmetrical Duos

An optimal opening guess tests two pairs of colors, such as [Red, Red, Blue, Blue]. This opening move immediately tests two entire color pools simultaneously while reducing the combinatorial state space from 1,296 possible codes down to fewer than 200 candidates.

2. Maintain Rigid Color Accounting

Track the total quantity of colored pegs confirmed by the feedback. If a guess of four distinct colors yields two white pegs and zero black pegs, you know for certain that exactly two of those four colors exist in the secret code, and two are completely absent.

3. Rotate Positions Methodically

When you confirm that a specific color belongs in the code but resides in the wrong position (indicated by a white peg), rotate its position systematically across adjacent slots in subsequent guesses rather than randomly scattering it.

4. Understand Knuth's 5-Guess Minimax Proof

In 1977, legendary computer scientist Donald Knuth proved mathematically that any Mastermind code can be cracked in 5 guesses or fewer. By choosing guesses that minimize the maximum number of remaining valid candidate codes regardless of the Codemaker's response, victory is mathematically guaranteed.

Game Features

🎯 Authentic Decoding Board

Realistic 10-row board rendering with 3D shaded pegs, specular lighting, and feedback holes.

🔒 1,296 Possible Permutations

Full support for repeated colors provides authentic classic tournament challenge rules.

📱 Responsive Touch Controls

Tap color bubbles to select and fill active slots with effortless mobile responsiveness.

🔊 Synthesized Audio Cues

Native Web Audio feedback for peg insertions, row submissions, and fanfare celebrations.

Frequently Asked Questions

Do feedback pegs tell me which specific color is right? +
No. The key pegs indicate how many colors are correct in position (black/red) and how many are correct in color only (white), but they never reveal which specific slot they correspond to. Deducing which peg corresponds to each clue is the core challenge.
Can duplicate colors appear in the code? +
Yes! The secret code can contain two, three, or even four pegs of the same color, generating 6^4 = 1,296 unique possible codes.
What happens if I run out of all 10 rows? +
If 10 guesses elapse without finding the exact code, the shield over the top secret row slides open to reveal the hidden code.