The deduction board game
Classic Mastermind: the codemaker picks a hidden sequence of 4 pegs, each chosen from 6 colours (repeats allowed). The codebreaker has 10 attempts to crack it. After each guess, the codemaker responds with:
- A black peg for each peg that is the right colour and in the right position.
- A white peg for each peg that is the right colour but in the wrong position.
The order of black/white pegs in the response is intentionally arbitrary — you know how many of each, not which of your pegs earned them. That ambiguity is the puzzle's engine.
Why it's elegant
Mastermind is a near-perfect teaching puzzle for constraint propagation. Each guess-and-response pair prunes the space of possible codes; an optimal player using Knuth's algorithm can solve any 4-peg/6-colour code in 5 guesses or fewer, with an average of 4.476. Casual players typically need 6–8.
How to play
- The codemaker sets a hidden code of 4 pegs, each one of 6 colours (repeats allowed).
- The codebreaker submits guesses — 4 pegs each.
- After every guess, the codemaker responds with:
- 1 black peg per peg that's the right colour AND the right position.
- 1 white peg per peg that's the right colour but a wrong position.
- The order of black and white pegs is arbitrary — you don't learn which specific pegs earned which response.
- Crack the code within 10 guesses to win.
- Pegs can repeat in the code — guessing four-of-a-kind is legal.
Strategy tips
- Use Knuth's first move: 1122 (or any two pairs). It maximises information from the first response.
- Track every consistent code. After each response, eliminate every code that wouldn't give the same response to your guess — only the consistent set remains.
- Guess to learn, not to win. Early guesses should be chosen to maximally split the remaining possibility space, even if you "know" they're wrong.
- Don't reuse colours until you've tested them. If you've used all 6 colours in 2 guesses and gotten no whites, those colours aren't in the code.
- White pegs are local information. A white peg narrows colour-set but not position; use it accordingly.
Play now
InteractivePrefer to read first? Scroll up for the rules and strategy tips.