Select number of boxes in the combination:

Select number of available colours:

Welcome to codeBreaker

If you've never played the classic board game Mastermind before, click the Game Instructions button below to learn the rules. Once you're familiar with the game, read these instructions to learn how to use this page.

The main game controls are in the bar at the top of the window. The menus on the left allow you to set the difficulty of the game by choosing the number of pegs in the combination and the number of available colours. The classic version of the game is played with four pegs and six colours, so these are the default values.

When you're ready to play, choose a game mode with the buttons on the right. To guess a code created by the game, click Start Game. To enter your own code and watch the algorithm solve it, click Enter Code. To review the game instructions at any time, click Instructions. Once you've started a game, the number of possible combinations that can be made from the number of pegs and colours chosen will be displayed below these buttons.

The playing surface is displayed at the bottom of the screen. The bottom row shows all of the available colours in the game; click these to fill in your guess or your code in the row above. This row will display the number of empty pegs that was chosen for the game. The currently selected peg is blinking. When you select a colour from the bottom row, the blinking peg will fill with that colour and the next open peg to the right will blink. To fill in a different peg, simply click on it to select it. To remove a colour, double-click the peg.

When the selection row is filled in, the Submit Guess or Submit Code button will appear, depending on the game mode. If your combination is ready, click to submit.

Game instructions

codeBreaker is based on the classic board game Mastermind, in which one player creates a code and the other player tries to guess it. After each guess, the player who created the code gives the guesser clues to help with their next guess.

The code is a sequence of colours. In the original game, the code is made up of four coloured pegs of six possible colours. In codeBreaker, you can increase the difficulty of the game by increasing the code size up to 16 pegs and the colour palette up to 12 colours.

Click Start Game to create a new code and begin guessing.

Enter your guess by clicking the coloured squares in the row at the bottom of the screen. Once the row above is filled, click Submit Guess to find out how close your guess is to the solution.

Each guess you submit will be scored by the game to give you clues for your next guess. For each correct colour in the correct spot in the sequence, a small black circle will be displayed to the left of your guess. For each correct colour in the incorrect order, a white circle will be displayed. If none of the colours you selected are in the code, no circles will appear. There is no significance to the order of the black and white circles.

Congratulations!

You have successfully solved the puzzle.

Your code had pegs and different colours, which could create a total of possible combinations. You solved it in guesses.

Code solved

The codeBreaker algorithm has solved the code in guesses.

There are possible combinations. The algorithm performed checks.