Mastermind is the classic two player game where you have to work out your opponents hidden coloured peg sequence in the least amount of guesses.

## Objective

Both players initially set their hidden peg sequence. The game type specifies the number of pegs and the number of colour combinations you are allowed to select from. The classic game uses 4 pegs and 8 colour combinations. Once both players have chosen their hidden peg combinations the main game starts. Each player can then submit a guess at any time and they are given a result back from that guess. The result from a guess will be separated into two different categories, a guess which is correct in both colour and position, and a correct colour code peg placed in the wrong position. For example if your hidden sequence was as follows:

Your opponent guesses:

They would be given the result of [1,1] which represents 1 peg in the correct position and colour (the white peg), and 1 peg which is the correct colour but incorrect position (the green peg). Each player is given a limited number of guesses and time determined by the game type to try and come up with their opponents hidden sequence. The player who guesses their opponents code in the least number of guesses is the winner. In the event of a tie the player submitting the correct solution first will be the winner. If neither player guesses the correct solution the game will be a draw.

If the game type allows duplicates you can put duplicate coloured pegs in your hidden sequence in any order or quantity. If there are duplicate colours in the guess, they cannot all be awarded a correct result unless they correspond to the same number of duplicate colours in the hidden code. For example if your hidden sequence was as follows:

Your opponent guesses:

They would be given the result [1,2] which represents 2 pegs in the correct position and colour (the first 2 red pegs), and 1 peg which is the correct colour but incorrect position (the light blue peg). No indication would be given there is a third red peg in the hidden sequence.

## Useful Links

Use the links below to get a working example that just randomly guesses combinations: