Free code-breaking logic game

Play Mastermind Online

A secret code of coloured pegs is waiting to be broken. After every guess you are told how many pegs are exactly right and how many are the right colour in the wrong place. Read those clues, reason out the hidden code, and crack it before you run out of rows.

Timer 00:00
Guesses left 0

Tap a colour to drop it into the next slot, tap a placed peg to remove it, then press Check. Dark feedback pegs mark a peg that is the right colour in the right place; light pegs mark the right colour in the wrong place.

What is Mastermind?

Mastermind is a code-breaking game for one guesser against a hidden code. The code is a row of coloured pegs — four in the classic game — and each position is chosen from a fixed set of colours. Colours may repeat, so the same colour can appear more than once, or not at all.

You break the code by making guesses. After each guess you are given clue pegs: one black peg for every peg that is the right colour in the right position, and one white peg for every peg that is the right colour but in the wrong position. The clues are never tied to a particular slot, so deciding which peg earned which clue is the whole challenge.

  • The hidden code is a row of coloured pegs.
  • Each slot is one colour from the palette; colours can repeat.
  • A black clue: right colour, right place.
  • A white clue: right colour, wrong place.
  • Crack the exact code before the rows run out to win.

How to play here

Tap a colour in the palette and it drops into the next empty slot of your current row, filling from the left. Tap a peg you have already placed to take it back out, or use Clear to empty the whole row. When all the slots are full, press Check to score the guess.

Your clues then appear beside the row as dark and light feedback pegs, and the completed guess stays on the board so you can compare it with the next one. The counter at the top shows how many rows you have left.

  • Tap palette colours to fill the row from the left.
  • Tap a placed peg to remove it; Clear empties the row.
  • Press Check to score a full row.
  • Dark pegs = right colour and place; light pegs = right colour only.
  • Watch the guesses-left counter and choose your levels.

Reading the feedback

The clue pegs are unordered: a row scored with one black and two white pegs tells you that, in total, one peg is perfect and two more are right colours sitting in the wrong slots — but not which ones. The skill is turning that summary into placement.

Add the black and white pegs together and you learn how many of your guessed colours appear in the code at all. If a four-peg guess scores nothing, none of those colours is used; if it scores four pegs of any kind, every colour you played is in the code somewhere.

  • Total clue pegs = how many of your colours the code contains.
  • Black pegs alone tell you how many are perfectly placed.
  • Zero clues means none of those colours is used — a big elimination.
  • Clues never say which slot, so combine several rows.
  • Repeated colours are counted to their multiplicity, no more.

A deduction strategy

Strong players spend the first guesses gathering information rather than trying to win outright. A useful opening is to test colours in pairs or to play a row of a single colour, which immediately tells you how many of that colour the code holds. A couple of such probes can pin down the exact colour content.

Once you know which colours are present and how many of each, switch to placement. Change one peg at a time and watch a white clue turn black to lock a colour into its slot. Keep a mental list of what every row has ruled out — careful Mastermind is pure logic, and a known method by Donald Knuth guarantees the four-colour code in five guesses or fewer.

Difficulty levels and why play online

Easy hides a four-peg code drawn from six colours — the classic game and the best place to learn to read the clues. Medium keeps four pegs but widens the palette to eight colours, while Hard stretches the code to five pegs and Expert to six, each with eight colours and a few extra rows to work in.

Playing online does the bookkeeping for you: the clues are scored instantly and exactly, every past guess stays visible for comparison, the timer tracks your solve and your game saves locally so you can return to a tricky code. With repeats allowed and no hints, it is your reasoning against the board.

  • Easy: a 4-peg code from 6 colours, 10 rows.
  • Medium: a 4-peg code from 8 colours, 10 rows.
  • Hard: a 5-peg code from 8 colours, 12 rows.
  • Expert: a 6-peg code from 8 colours, 12 rows.

FAQ

Mastermind FAQ

What is Mastermind?

Mastermind is a code-breaking deduction game. A hidden code of coloured pegs is set, and you guess it row by row, using black and white clue pegs after each guess to reason out the exact colours and positions.

What do the black and white pegs mean?

A black (dark) clue peg means one of your pegs is the right colour in the right position. A white (light) clue peg means a peg is the right colour but in the wrong position. The clues are not tied to particular slots.

Can colours repeat in the code?

Yes. Each slot is chosen independently, so a colour can appear several times or not at all. Part of the puzzle is working out how many of each colour the code contains.

Is the first guess important?

The first guess is always blind, so use it to gather information rather than to win. Testing colours in pairs or playing one colour across the row quickly tells you how much of each colour the code holds.

How many guesses do I get?

It depends on the level: the easy and medium codes give you ten rows, while hard and expert give twelve. The counter at the top shows how many guesses remain.

Does Mastermind require luck?

Beyond the opening guess it is a game of logic. Every clue narrows the possibilities, and a careful player can always deduce the code — a known strategy solves the classic four-peg game in five guesses or fewer. It is free to play on phones, tablets and desktop.