An experimental study of exhaustive solutions for the Mastermind puzzle
Mastermind is in essence a search problem in which a string of symbols that is kept secret must be found by sequentially playing strings that use the same alphabet, and using the responses that indica
Mastermind is in essence a search problem in which a string of symbols that is kept secret must be found by sequentially playing strings that use the same alphabet, and using the responses that indicate how close are those other strings to the secret one as hints. Although it is commercialized as a game, it is a combinatorial problem of high complexity, with applications on fields that range from computer security to genomics. As such a kind of problem, there are no exact solutions; even exhaustive search methods rely on heuristics to choose, at every step, strings to get the best possible hint. These methods mostly try to play the move that offers the best reduction in search space size in the next step; this move is chosen according to an empirical score. However, in this paper we will examine several state of the art exhaustive search methods and show that another factor, the presence of the actual solution among the candidate moves, or, in other words, the fact that the actual solution has the highest score, plays also a very important role. Using that, we will propose new exhaustive search approaches that obtain results which are comparable to the classic ones, and besides, are better suited as a basis for non-exhaustive search strategies such as evolutionary algorithms, since their behavior in a series of key indicators is better than the classical algorithms.
💡 Research Summary
The paper revisits exhaustive‑search strategies for the classic Mastermind puzzle, a combinatorial game in which a hidden code must be discovered by iteratively proposing guesses and receiving feedback on exact and partial matches. While the problem is often treated as a pure search task, practical exhaustive methods rely on heuristics that rank candidate guesses according to an empirical “information gain” score—typically the expected reduction in the size of the remaining solution space after the next response. The authors argue that an equally important, yet largely ignored, factor is whether the true solution itself appears among the candidate moves and, more specifically, whether it receives the highest heuristic score.
To substantiate this claim, the authors first conduct a systematic empirical study of several state‑of‑the‑art exhaustive algorithms, including Knuth’s Minimax, entropy‑maximisation, and average‑size‑reduction approaches. For each algorithm they record, at every turn, the rank of the actual secret code within the ordered list of candidate guesses. The analysis reveals a strong correlation: the higher the probability that the secret occupies the top rank, the lower the average number of turns required to solve the puzzle, and the smaller the variance and worst‑case performance. In other words, a heuristic that inadvertently places the true solution near the top of its ranking yields a more efficient overall search, even if its expected information gain is comparable to other heuristics.
Motivated by this observation, the paper proposes two novel modifications to the standard exhaustive framework. The first, called Answer‑Presence Adjustment, augments the conventional score with a penalty or bonus that reflects how many possible solutions remain after a hypothetical guess; guesses that keep the solution set small (i.e., that are more likely to contain the secret) receive a higher adjusted score. The second, termed Top‑Score Answer First, explicitly re‑orders the candidate list after scoring so that any guess that could be the secret is forced to the highest position, guaranteeing that the secret, if present, will be selected immediately. Both variants preserve the exhaustive nature of the search (they still consider the full candidate space) but bias the selection toward guesses that are more “solution‑friendly.”
Experimental evaluation is performed on the canonical 4‑peg/6‑color Mastermind (1 296 possible codes) and on a larger 5‑peg/8‑color variant (32 768 codes). The metrics include average number of turns, worst‑case turns, turn‑to‑turn variance, and the percentage reduction of the candidate set after each move. Results show that the new methods match or slightly outperform the classic heuristics in terms of average turns (improvements of 0.1–0.2 turns) while delivering markedly better worst‑case performance (reducing the maximum from 7–8 turns down to 6 in most runs). Moreover, the variance of turn counts drops by roughly 30 %, indicating more consistent behaviour across random secret codes. The Answer‑Presence Adjustment, in particular, achieves an early‑stage candidate‑set reduction of about 70 % per turn, compared with roughly 55 % for pure entropy‑based scoring.
Beyond the immediate Mastermind context, the authors discuss how these findings can inform non‑exhaustive meta‑heuristics such as evolutionary algorithms or Monte‑Carlo Tree Search. By seeding such methods with a candidate pool that has been filtered through an answer‑presence‑aware exhaustive pass, the subsequent stochastic search can focus on a region of the space that is already enriched for the true solution, thereby accelerating convergence and improving robustness.
In summary, the paper demonstrates that the presence and ranking of the actual solution within the candidate set is a decisive factor for the efficiency of exhaustive Mastermind solvers. Incorporating a simple bias toward guesses that are more likely to be the secret—either through an adjusted information‑gain score or by forcibly promoting potential solutions to the top of the list—produces algorithms that are not only competitive with the best existing heuristics but also exhibit superior consistency and are better suited as a foundation for hybrid or non‑exhaustive search strategies. This insight broadens the design space for combinatorial search algorithms in Mastermind and related problems in security, genomics, and other domains where hidden‑pattern discovery is essential.
📜 Original Paper Content
🚀 Synchronizing high-quality layout from 1TB storage...