# Mastermind

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 (c_{1},c_{2},c_{3},c_{4}), each chosen from a set of six possible colors where repetitions are allowed. Thus, there are 6^{4}=1296 possible codes.

The codebreaker then tries to guess the code by repeatedly proposing a guess (g_{1},g_{2},g_{3},g_{4}). After each guess, the codemaker tells the codebreaker two numbers (b,w):

- b is the number of correct colors in the correct positions, i.e., the number of positions j such that c
_{j}=g_{j}holds - w is the number of colors that are part of the code but not in the correct positions, i.e., the number of positions j such that c
_{j}≠g_{j}holds, but where c_{j}=g_{k}for some k where g_{k}has not been used in another hit

_{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.

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):

- Minimize Maximal Number of Remaining Possibilities
- Maximize Entropy of Answer Distribution
- Minimize Expected Number of Remaining Possibilities
- Maximize Number of Non-Empty Possible Answers

- [1] D.E. Knuth:
*The computer as master mind*, Journal on Recreational Mathematics, 9(1):1–6, 1976. - [2] B. Kooi:
*Yet another Mastermind strategy*, International Computer Games Association (ICGA), 28(1):13–20, 2005. - [3] K. Koyoma and T. Lai:
*An optimal Mastermind strategy*, Journal of Recreational Mathematics, 25(4):251–256, 1993. - [4] E. Neuwirth:
*Some strategies for Mastermind*, Zeitschrift für Operations Research (ZOR), 26:257–278, 1982.