← Home

The computer cracks your code

Swap roles: set a secret code, and the computer cracks it move by move, explaining what it deduces from each piece of feedback.

Level

4 pegs, 6 colors, repeats allowed

Set your secret code

How the computer does it

It has no intuition and never sees your code: all it gets is the feedback on each guess, just like you when you play. Its method comes down to three steps, repeated to the end.

  1. List. Before the first guess, every code of the level is possible.
  2. Rule out. After each piece of feedback, it keeps only the codes that, in place of yours, would have given exactly the same number of black and white pegs.
  3. Choose. Among the remaining codes, it plays the one that leaves the fewest in the worst case, whatever the next feedback turns out to be.

What you can take from it for your own games

You can't run through hundreds of codes in your head, but the principle stays the same: a good guess teaches you something whatever the feedback. A guess that can only get one possible answer teaches you nothing.

Look at the first move, too: on Classic, the computer opens with two pairs of colors, and on Easy, where the code has no repeats, with four different colors.

A black peg means a right color in the right spot, a white peg a right color in the wrong spot. The feedback shown here is worked out from the code you built, with the same rule as in the game.

For the opposite kind of help, when you're the one searching, there's the Mastermind solver. And if you're new to the game, the tutorial teaches you to read the feedback in 2 minutes before you play a real game.