Mastermind rules: a complete guide to get started
- A secret code of 4 or 5 colored pegs; the order matters.
- After each guess: a black peg per color in the right place, a white peg per color in the wrong place.
- Find the code within 12 guesses (10 at the Classic level).
Mastermind is a game of logic and deduction: a code of colors is hidden, and you have to find it within a limited number of guesses, using the clues the game gives you after each one. This guide covers everything you need for your first game: the goal, how to read black and white pegs (with examples), duplicates, the levels and the game modes.
Mastermind in three sentences
- A secret code of 4 or 5 colored pegs is hidden. The order matters: red, blue, green, yellow is not the same code as blue, red, green, yellow.
- You make a guess. The game answers with a black peg for each color in the right place and a white peg for each color that is in the code but in the wrong place.
- You win by finding the exact code before you run out of guesses: 12 guesses here (10 at the Classic level).
In the board game, one player (the codemaker) sets the code and gives the feedback, and the other (the codebreaker) searches. Here, the computer plays the codemaker. If you would rather learn by playing, the tutorial guides you through a first game.
How to make a guess
On screen, the board with your previous guesses is at the top. Below it are the input row, where you build your guess, and the color palette.
- Pick a color in the palette: it goes into the selected slot of the input row, and the next slot is selected.
- To correct, click a slot in the input row: it empties and becomes the selected slot. The Delete button removes the last peg placed.
- When the row is full, the Submit button becomes active.
- Your guess moves up into the board with its feedback, and a new input row is waiting.
With the keyboard
| Key | Effect |
|---|---|
| 1 to 9 | Places the matching color (1 red, 2 blue, 3 green, 4 yellow, 5 orange, 6 purple, 7 pink, 8 cyan, 9 brown) |
| 0 | Places the tenth color, gray (Extreme level) |
| Enter | Submits the guess |
| Backspace | Deletes the last peg placed |
| R | Copies your previous guess, so you only change part of it |
Two aids worth knowing
- Crossing out a color: right-click a color in the palette (long press on mobile). Handy to mark a color you know is not in the code.
- Numbers in the pegs: the 123 button shows each peg's key number inside it. Useful if you have trouble telling some colors apart.
Reading the feedback: black and white pegs
This is the heart of the game. After each guess, small feedback pegs appear next to your row:
- A black peg: one of your colors is in the code, in the right place.
- A white peg: one of your colors is in the code, but in another place.
The feedback pegs are not lined up with your pegs. The game always shows blacks first, then whites, then empty slots. A black peg in the first slot does not mean your first peg is right, and an empty slot does not point to any particular peg. You know how many colors are in the right or the wrong place, never which ones. You find out by comparing several guesses.
Example 1: no duplicates
1 black, 1 white. The red is in its place (black). The green is in the code, but in the third position, not the second (white). Orange and purple are not in the code: they get nothing.
Example 2: one color played three times
1 black, 1 white. The code contains two reds and you played three. The first is in its place (black). A second one matches the code's other red, in the wrong place (white). The third red is one too many: it gets nothing.
Example 3: duplicates on both sides
1 black, 2 whites. The blue in the second position is in its place (black). The code has a second blue: another of your blues matches it, in the wrong place (white). Your third blue is one too many. The red is in the code, but in the first position (white).
Example 4: with 5 pegs
2 blacks, 2 whites. The blue in the second position and the cyan are in their places. The blue in the first position matches the blue in the code's third position (white). The code only has one red: only one of your two reds gets a white.
A method to count without mistakes
- Count the blacks first: the positions where your peg and the code's peg are identical. Set those pegs aside, in the code and in the guess.
- Then count the whites, color by color, on what is left: if the code still has 1 red and your guess still has 2 reds, that makes 1 white. You always take the smaller of the two numbers.
As a result, a peg in the code never gives more than one feedback peg. That explains the verdicts in examples 2, 3 and 4. All four examples on this page were checked with the game engine.
Winning and losing
- You win when every feedback peg is black: 4 blacks for a 4-peg code, 5 blacks for a 5-peg code.
- You lose if your last guess does not give the code. In solo play, the code is then shown to you.
The five levels
| Level | Code pegs | Colors | Duplicates | Guesses | Possible codes |
|---|---|---|---|---|---|
| Easy | 4 | 6 | no | 12 | 360 |
| Classic | 4 | 6 | yes | 10 | 1,296 |
| Medium | 4 | 8 | yes | 12 | 4,096 |
| Hard | 5 | 8 | yes | 12 | 32,768 |
| Extreme | 5 | 10 | yes | 12 | 100,000 |
- Easy: the four colors of the code are all different. The best level to learn to read the feedback.
- Classic: the board game setup, 4 pegs, 6 colors, duplicates allowed, 10 guesses. It is also the one Donald Knuth studied.
- Medium: two more colors.
- Hard: one more peg. It is the Super Mastermind setup.
- Extreme: 5 pegs and all ten colors.
The palette always follows the same order: red, blue, green, yellow, orange, purple, pink, cyan, brown, gray. With 6 colors only the first six are in play; with 8, the first eight.
How many combinations are there?
Classic Mastermind has 1,296 combinations: 6 possible colors for each of the 4 pegs, so 6 × 6 × 6 × 6. In general, when duplicates are allowed, you multiply the number of colors by itself as many times as there are pegs.
| Setup | Calculation | Combinations |
|---|---|---|
| 4 pegs, 6 colors, no duplicates | 6 × 5 × 4 × 3 | 360 |
| 4 pegs, 6 colors, duplicates | 64 | 1,296 |
| 4 pegs, 8 colors, duplicates | 84 | 4,096 |
| 5 pegs, 8 colors, duplicates | 85 | 32,768 |
| 5 pegs, 10 colors, duplicates | 105 | 100,000 |
How many guesses? 10 on the board, 12 here
The classic board game most often has 10 rows, so 10 guesses (some editions have 8 or 12). Here you get 12 guesses at the Easy, Medium, Hard and Extreme levels, and 10 at the Classic level, to match the board exactly.
That is more than a methodical player needs: in the classic format, a good method finds any code in 5 guesses at most.
Game modes
Solo
A code is drawn at random for each game. The timer runs and, if you are logged in, your game counts for the leaderboard. It compares sets of 3 games played in a row, daily challenges included: the guesses of the three games are added up, and time only separates two equal totals. A lost or abandoned game costs the maximum, so consistency beats luck.
Practice
Practice mode has no timer and no leaderboard. It shows how many codes are still possible after each guess, so you see at once what your move eliminated. It is the best place to learn.
Daily challenge
Every day, five codes are set, one per level (Easy, Classic, Medium, Hard, Extreme), the same for everyone. You need an account and get one attempt per level. The daily leaderboard ranks players by number of guesses, then by time. After a loss, the code is not revealed on the same day. See the daily challenge.
With others: Race and Duel
- Race (2 to 20 players): everyone looks for the same code at the same time. The first to find it scores 3 points and starts a 30-second countdown; anyone who finds it within that time scores 1 point. A game is played over 1, 3, 5, 7 or 10 rounds.
- Duel (2 players): each one sets a secret code that the other must find. Whoever needs fewer guesses wins; if tied, time decides.
To invite someone, create a room and send them its 4-character code (letters and digits). Everything is explained in the multiplayer guide and in playing Mastermind with two players.
Tools
- The solver: enter your guesses and their feedback, and it gives you the remaining codes and a suggested move.
- The computer cracks your code: you choose a code, and the machine finds it while showing its reasoning.
- The printable board, to play on paper.
Five tips for your first game
- Start at Easy. Without duplicates, the feedback is simpler to read.
- Play four different colors on your first guess. At Easy you will always get at least two feedback pegs, and their number tells you how many of the two colors you did not play are in the code.
- Do not read the feedback position by position. It gives a count, not positions.
- Change only a little at a time. If you change only one peg (R key, then one correction), the change in the number of blacks tells you something directly.
- Before submitting, check that your guess is consistent with all the feedback you have received so far.
Frequently asked questions
More guides
- Playing Mastermind with two players: online (Race, Duel) and on paper Race, Duel or paper: the three ways to play with two, scoring, and giving feedback without mistakes.
- Multiplayer Mastermind online: challenge your friends Race and Duel modes, scoring, creating and joining a room, levels and tips to win.
This guide in other languages : 🇪🇸 Español · 🇮🇹 Italiano · 🇩🇪 Deutsch