Skip to main content
QUICK REVIEW

[Paper Review] An Optimal Mastermind (4,7) Strategy and More Results in the Expected Case

Geoffroy Ville|arXiv (Cornell University)|May 5, 2013
graph theory and CDMA systemsEngineering10 references4 citations
TL;DR

This paper presents an optimal strategy for solving the Mastermind game with 4 pegs and 7 colors (MM(4,7)) in the expected case, achieving an average of 4.676 guesses. It employs a depth-first branch and bound algorithm enhanced by tight upper bounds, dynamic lower bound evaluation, and symmetry-based guess equivalence detection to efficiently prune the search space and find the minimal expected number of guesses.

ABSTRACT

This paper presents an optimal strategy for solving the 4 peg-7 color Mastermind MM(4,7) in the expected case (4.676) along with optimal strategies or upper bounds for other values. The program developed is using a depth-first branch and bound algorithm relying on tight upper bound, dynamic lower bound evaluation and guess equivalence to prune symmetric tree branches.

Motivation & Objective

  • To determine the optimal expected-case solution for the Mastermind variant MM(4,7), where 4 pegs are chosen from 7 colors.
  • To extend prior work on expected-case optimal strategies beyond the classic MM(4,6) game.
  • To develop and apply algorithmic optimizations—such as dynamic lower bounds and guess equivalence detection—to reduce search space and improve computational efficiency.
  • To provide tight upper bounds for other MM(p,c) configurations, including MM(5,8), and to explore theoretical patterns in code distribution and zero-color usage.

Proposed method

  • A depth-first branch and bound algorithm is used to systematically explore the game tree while pruning suboptimal branches.
  • Tight upper bounds are computed at the start of each search to guide the pruning process and reduce unnecessary exploration.
  • Dynamic lower bound evaluation is applied during execution to further restrict the search space based on evolving constraints.
  • Guess equivalence is detected using color symmetries, allowing the algorithm to treat equivalent guesses as a single representative and avoid redundant computation.
  • A signature scheme is employed to efficiently represent and compare code sets, reducing the number of distinct codes examined at each step.
  • The algorithm is implemented in Perl for flexibility and ease of prototyping, with performance limitations noted for larger cases.

Experimental results

Research questions

  • RQ1What is the minimal expected number of guesses required to solve MM(4,7), and what strategy achieves this?
  • RQ2How can symmetry and equivalence in guesses be leveraged to reduce the computational complexity of solving Mastermind?
  • RQ3What is the role of 'zero color' (i.e., unused colors) in distinguishing remaining codes, especially in cases with fewer colors than pegs?
  • RQ4Can tighter upper bounds be established for MM(p,c) configurations beyond MM(4,7), particularly for MM(5,8)?
  • RQ5How do the structural properties of code distributions (e.g., number of colors used) affect the optimal strategy and expected guess count?

Key findings

  • The optimal expected-case solution for MM(4,7) requires an average of 4.676 guesses, which is the minimal known average for this configuration.
  • The strategy is derived using a depth-first branch and bound algorithm with dynamic lower bounds and symmetry-aware pruning.
  • For MM(4,7), the total number of possible codes is 2,401, and there are 14 possible answer grades (black and white peg combinations).
  • The study provides optimal strategies or tight upper bounds for several other MM(p,c) configurations, including MM(4,6), MM(5,8), and various (p,c) pairs up to p=7.
  • The results suggest a conjecture that MM(p,c) = MMe(p,c) when c ≥ p−1, indicating that zero colors become necessary for discrimination when color count is low relative to pegs.
  • The paper identifies potential algorithmic improvements such as two-phase search (first to find optimal L, then to find solution), and proposes that future work should use faster languages and external programs to cache and reuse intermediate results.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.