Mastermind
Crack the secret colour code. Black peg = right colour, right spot. White peg = right colour, wrong spot.
Last updated
How to play Mastermind
- Set the code length, number of colours and guesses, or keep the defaults.
- Click each slot to choose a colour, then click Submit guess.
- Use the feedback pegs to crack the code before you run out of guesses.
About this game
The computer picks a hidden sequence of colours. Each guess gets scored with two kinds of pegs: a black peg for every colour you placed in exactly the right position, and a white peg for every colour you guessed that's in the code but in the wrong spot — counted so each secret and guessed peg contributes to at most one feedback peg, the standard Mastermind scoring rule. Position of the feedback pegs doesn't correspond to position in your guess; only the counts of black and white matter.
Click a slot to cycle through colours (or tap a palette swatch, then a slot). Everything runs locally in your browser — the code is generated and checked in JavaScript, nothing is sent anywhere.
Questions about Mastermind
What do the black and white pegs mean?
A black peg is a right colour in the right place. A white peg is a right colour in the wrong place. Their order doesn’t match your guess.
What is a good strategy?
Start with a guess using two pairs of colours, such as red-red-blue-blue, and use each answer to rule out as many codes as possible.
Can the code repeat colours?
Only if Allow repeated colours is ticked.
Can every code be solved?
Yes. In the classic version, with 4 pegs and 6 colours, any code can be cracked in 5 guesses or fewer with the right strategy.