Comparing Evolutionary Algorithms to Solve the Game of MasterMind

  • Javier Maestro-Montojo
  • Juan Julián Merelo
  • Sancho Salcedo-Sanz
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7835)


In this paper we propose a novel evolutionary approach to solve the Mastermind game, and compare the results obtained with that of existing algorithms. The new evolutionary approach consists of a hierarchical one involving two different evolutionary algorithms, one for searching the set of eligible codes, and the second one to choose the best code to be played at a given stage of the game. The comparison with existing algorithms provides interesting conclusions regarding the performance of the algorithms and how to improve it in the future. However, it is clear that Entropy is a better scoring strategy than Most Parts, at least for these sizes, being able to obtain better results, independently of the evolutionary algorithm.


Evolutionary Algorithm Evolutionary Approach Mastermind Strategy Anticipation Strategy Apply Soft Computing 
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.
    Knuth, E.: The computer as Master Mind. Journal of Recreational Mathematics 9, 1–6 (1977)MathSciNetzbMATHGoogle Scholar
  2. 2.
    Irving, W.: Towards an optimum Mastermind strategy. Journal of Recreational Mathematics 11(2), 81–87 (1979)Google Scholar
  3. 3.
    Koyama, K., Lai, T.: An optimal Mastermind strategy. Journal of Recrational Mathematics 25(4), 251–256 (1993)zbMATHGoogle Scholar
  4. 4.
    Bestavros, A., Belal, A.: Master Mind: a game of diagnosis strategies. In: Bulletin of the Faculty of Engineering, Alexandria University, Alexandria (1986)Google Scholar
  5. 5.
    Kooi, B.: Yet another mastermind strategy. ICGA Journal 28(1), 13–20 (2005)MathSciNetGoogle Scholar
  6. 6.
    Chen, S.T., Lin, S.S., Huang, L.T.: A two-phase optimization algorithm for Mastermind. The Computer Journal 50(4), 435–443 (2007)CrossRefGoogle Scholar
  7. 7.
    Chen, S.T., Lin, S., Huang, L., Hsu, S.: Strategy optimization for deductive games. European Journal of Operational Research 183, 757–766 (2007)zbMATHCrossRefGoogle Scholar
  8. 8.
    Merelo, J.J., Mora, A.M., Cotta, C., Runarsson, T.P.: An experimental study of exhaustive solutions for the Mastermind puzzle. ARXiV (2012)Google Scholar
  9. 9.
    Shapiro, E.: Playing Mastermind logically. SIGART Bulleting 85, 28–29 (1983)CrossRefGoogle Scholar
  10. 10.
    Swaszek, P.: The mastermind novice. Journal of Recreational Mathematics 30, 130–138 (2000)Google Scholar
  11. 11.
    Temporal, A., Kovacs, T.: A heuristic hill climbing algorithm for Mastermind. In: Proc. of the UK Workshop on Computational Intelligence, Bristol, UK, pp. 183–196 (2003)Google Scholar
  12. 12.
    Bernier, J., Herráiz, C., Merelo-Guervós, J.J., Olmeda, S., Prieto, A.: Solving Mastermind using GAs and simulated annealing: a case of dynamic constraint optimization. In: Proc. of the 4th International Conference on Parallel Problem Solving from Nature, London, UK, pp. 554–563 (1996)Google Scholar
  13. 13.
    Bento, L., Pereira, L., Rosa, A.: Mastermind by evolutionary algorithms. In: Proc. of the Sixth Annual Workshop on Selected Areas in Cryptography, Kingston, Ontario, Canada, pp. 307–311 (1999)Google Scholar
  14. 14.
    Kalister, T., Camens, D.: Solving Mastermind using Genetic Algorithms. In: Cantú-Paz, E., Foster, J.A., Deb, K., Davis, L., Roy, R., O’Reilly, U.-M., Beyer, H.-G., Kendall, G., Wilson, S.W., Harman, M., Wegener, J., Dasgupta, D., Potter, M.A., Schultz, A., Dowsland, K.A., Jonoska, N., Miller, J., Standish, R.K. (eds.) GECCO 2003. LNCS, vol. 2724, pp. 1590–1591. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  15. 15.
    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
  16. 16.
    Some A. Uthor, A fine paper (2012)Google Scholar
  17. 17.
    Bergman, L., Goossens, D., Leus, R.: Efficient solutions for Mastermind using genetic algorithms. Computers & Operations Research 36(6), 1880–1885 (2009)CrossRefGoogle Scholar
  18. 18.
    Runarsson, T.P., Merelo-Guervos, J.J.: Adapting heuristic Mastermind strategies to evolutionary algorithms. In: Proc. of the International Workshop on Nature Inspired Cooperative Strategies for Optimization, Granada, Spain (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Javier Maestro-Montojo
    • 1
  • Juan Julián Merelo
    • 2
  • Sancho Salcedo-Sanz
    • 2
  1. 1.Department of Signal Processing and CommunicationsUniversidad de AlcaláMadridSpain
  2. 2.Departamento de Arquitectura y Tecnología de ComputadoresUniversidad de GranadaGranadaSpain

Personalised recommendations