← Back to the game

Mastermind rules: a complete guide to get started

In short
  • 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.

🔮 Play Mastermind

Mastermind in three sentences

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.

With the keyboard

KeyEffect
1 to 9Places the matching color (1 red, 2 blue, 3 green, 4 yellow, 5 orange, 6 purple, 7 pink, 8 cyan, 9 brown)
0Places the tenth color, gray (Extreme level)
EnterSubmits the guess
BackspaceDeletes the last peg placed
RCopies your previous guess, so you only change part of it

Two aids worth knowing

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:

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

  1. 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.
  2. 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

The five levels

LevelCode pegsColorsDuplicatesGuessesPossible codes
Easy46no12360
Classic46yes101,296
Medium48yes124,096
Hard58yes1232,768
Extreme510yes12100,000

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.

SetupCalculationCombinations
4 pegs, 6 colors, no duplicates6 × 5 × 4 × 3360
4 pegs, 6 colors, duplicates641,296
4 pegs, 8 colors, duplicates844,096
5 pegs, 8 colors, duplicates8532,768
5 pegs, 10 colors, duplicates105100,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

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

Five tips for your first game

  1. Start at Easy. Without duplicates, the feedback is simpler to read.
  2. 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.
  3. Do not read the feedback position by position. It gives a count, not positions.
  4. 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.
  5. Before submitting, check that your guess is consistent with all the feedback you have received so far.

Frequently asked questions

Play now

More guides

This guide in other languages : 🇪🇸 Español · 🇮🇹 Italiano · 🇩🇪 Deutsch