Embedded Systems Group (ES)


This tool offers some well-known strategies for solving the Mastermind board game like the MinMax, Entropy, ExpectedSize and MaxParts strategies. Mastermind is a simple two-player code-breaking board game. In the game, one player is the codemaker and the other is the codebreaker. The codemaker secretly selects a code consisting of an ordered sequence of four colors (c1,c2,c3,c4), each chosen from a set of six possible colors where repetitions are allowed. Thus, there are 64=1296 possible codes.

The codebreaker then tries to guess the code by repeatedly proposing a guess (g1,g2,g3,g4). After each guess, the codemaker tells the codebreaker two numbers (b,w):

While b is clearly understood, the definition of w is often difficult to understand. Mathematically, it is can be computed as w=(∑j=0..5 min(num(j,c),num(j,g)))-b where num(j,c) is the number of times color j occurs in the code c.

In the tool below, one can specify the number of colors, the number of places (code length), and a strategy to be used by the codebreaker. Moreover, a code to be broken has to be specified which is, of course, kept secret from the codebreaker. The tool then simulates the game where the codebreaker makes guesses according to the selected strategy to break the code.

secret code

The above strategies can also be drawn as trees where each node contains the guess made by the codebreaker (we have additionally added the number of possible codes remaining when making the guess):