Finding Better Solutions to the Mastermind Puzzle Using Evolutionary Algorithms

  • Juan J. Merelo-Guervós
  • Thomas Philip Runarsson
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6024)


The art of solving the Mastermind puzzle was initiated by Donald Knuth and is already more than thirty years old; despite that, it still receives much attention in operational research and computer games journals, not to mention the nature-inspired stochastic algorithm literature. In this paper we revisit the application of evolutionary algorithms to solving it and trying some recently-found results to an evolutionary algorithm. The most parts heuristic is used to select guesses found by the evolutionary algorithms in an attempt to find solutions that are closer to those found by exhaustive search algorithms, but at the same time, possibly have better scaling properties when the size of the puzzle increases.


Evolutionary Algorithm Exhaustive Search Board Game Local Entropy Consistent Solution 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Berghman, L., Goossens, D., Leus, R.: Efficient solutions for Mastermind using genetic algorithms. Computers and Operations Research 36(6), 1880–1885 (2009), zbMATHCrossRefGoogle Scholar
  2. 2.
    Bernier, J.L., Herráiz, C.I., Merelo-Guervós, J.J., Olmeda, S., Prieto, A.: Solving mastermind using GAs and simulated annealing: a case of dynamic constraint optimization. In: Ebeling, W., Rechenberg, I., Voigt, H.-M., Schwefel, H.-P. (eds.) PPSN 1996. LNCS, vol. 1141, pp. 554–563. Springer, Heidelberg (1996), CrossRefGoogle Scholar
  3. 3.
    Bestavros, A., Belal, A.: Mastermind, a game of diagnosis strategies. Bulletin of the Faculty of Engineering, Alexandria University (December 1986),, available from
  4. 4.
    Irving, R.W.: Towards an optimum mastermind strategy. Journal of Recreational Mathematics 11(2), 81–87 (1978–1979)Google Scholar
  5. 5.
    Kendall, G., Parkes, A., Spoerer, K.: A survey of NP-complete puzzles. ICGA Journal 31(1), 13–34 (2008), Google Scholar
  6. 6.
    Knuth, D.E.: The computer as Master Mind. J. Recreational Mathematics 9(1), 1–6 (1976–1977)MathSciNetGoogle Scholar
  7. 7.
    Kooi, B.: Yet another Mastermind strategy. ICGA Journal 28(1), 13–20 (2005), MathSciNetGoogle Scholar
  8. 8.
    Merelo-Guervós, J.J., Castillo, P., Rivas, V.: Finding a needle in a haystack using hints and evolutionary computation: the case of evolutionary MasterMind. Applied Soft Computing 6(2), 170–179 (2006) ,; CrossRefGoogle Scholar
  9. 9.
    Neuwirth, E.: Some strategies for Mastermind. Zeitschrift fur Operations Research. Serie B 26(8), B257–B278 (1982)zbMATHMathSciNetGoogle Scholar
  10. 10.
    Runarsson, T.P., Merelo, J.J.: Adapting heuristic Mastermind strategies to evolutionary algorithms. In: NICSO 2010 Proceedings. LNCS. Springer, Heidelberg (2010) (to be published) ArXiV: Google Scholar
  11. 11.
    Stuckman, J., Zhang, G.Q.: Mastermind is NP-complete. CoRR abs/cs/0512049 (2005)Google Scholar
  12. 12.
    Wikipedia: Mastermind (board game) — Wikipedia, The Free Encyclopedia (2009), (Online; accessed 9-October-2009)

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Juan J. Merelo-Guervós
    • 2
  • Thomas Philip Runarsson
    • 1
  1. 1.School of Engineering and Natural SciencesUniversity of Iceland 
  2. 2.Department of Architecture and Computer Technology, ETSIITUniversity of GranadaSpain

Personalised recommendations