← whatifs.fun

Code Breaker

Classic Mastermind Logic Game
0
Streak
Best
0
Wins
0
Games
Secret Code
Score

What Is Code Breaker?

Code Breaker is a free browser version of the classic Mastermind board game invented by Mordecai Meirowitz in 1970. Your goal is to deduce a hidden sequence of colored pegs using logical elimination. After each guess, black and white feedback pegs tell you exactly how close you are — no words, just pure logic.

The optimal Mastermind strategy can always solve the code in 5 or fewer guesses — a fact proven mathematically by computer scientist Donald Knuth in 1977.

How It Works

Difficulty Modes

Easy — 4 colors, no duplicates, 4 positions. Great for beginners.
Medium — 6 colors, no duplicates, 4 positions. The classic ruleset.
Hard — 6 colors, duplicates allowed, 4 positions. A significant jump in difficulty.
Expert — 8 colors, duplicates, 5 positions. Only for seasoned code-breakers.

Reading the Feedback

After each guess you receive up to 4 feedback pegs (5 on Expert). A black peg means one of your colors is in exactly the right position. A white peg means one of your colors is in the code but in the wrong position. The pegs give no indication of which slot they refer to — that's for you to work out.

FAQs

How do you play Mastermind?

Choose a difficulty, then guess the secret color code by tapping colors into each position and submitting. After each guess you get black pegs (right color, right position) and white pegs (right color, wrong position). Use the feedback to narrow down the code in 10 guesses or fewer.

What is the best first guess in Mastermind?

A widely used optimal first guess is two pairs of different colors — for example Red, Red, Blue, Blue. This strategy, proven by Donald Knuth, allows the solver to always crack any 4-peg, 6-color code in 5 or fewer guesses. In Easy mode (no duplicates), something like Red, Blue, Green, Yellow is ideal.

Is Mastermind a game of logic or luck?

Mastermind is almost entirely logic. While the secret code is set randomly, a skilled player using systematic elimination can always solve the puzzle optimally. The game rewards deductive reasoning and process of elimination far more than chance.

Related Games

Last updated: March 2026