Hardness of Mastermind

  • Giovanni Viglietta
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7288)

Abstract

Mastermind is a popular board game released in 1971, where a codemaker chooses a secret pattern of colored pegs, and a codebreaker has to guess it in several trials. After each attempt, the codebreaker gets a response from the codemaker containing some information on the number of correctly guessed pegs. The search space is thus reduced at each turn, and the game continues until the codebreaker is able to find the correct code, or runs out of trials.

In this paper we study several variations of #MSP, the problem of computing the size of the search space resulting from a given (possibly fictitious) sequence of guesses and responses. Our main contribution is a proof of the #P-completeness of #MSP under parsimonious reductions, which settles an open problem posed by Stuckman and Zhang in 2005, concerning the complexity of deciding if the secret code is uniquely determined by the previous guesses and responses. Similarly, #MSP stays #P-complete under Turing reductions even with the promise that the search space has at least k elements, for any constant k. (In a regular game of Mastermind, k = 1.)

All our hardness results hold even in the most restrictive setting, in which there are only two available peg colors, and also if the codemaker’s responses contain less information, for instance like in the so-called single-count (black peg) Mastermind variation.

Keywords

Mastermind code-breaking game counting search space 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
  2. 2.
    Chen, Z., Cunha, C., Homer, S.: Finding a Hidden Code by Asking Questions. In: Cai, J.-Y., Wong, C.K. (eds.) COCOON 1996. LNCS, vol. 1090, pp. 50–55. Springer, Heidelberg (1996)CrossRefGoogle Scholar
  3. 3.
    Chvátal, V.: Mastermind. Combinatorica 3, 325–329 (1983)MathSciNetMATHCrossRefGoogle Scholar
  4. 4.
    Dyer, M., Goldberg, L.A., Greenhill, C., Jerrum, M.: On the Relative Complexity of Approximate Counting Problems. In: Jansen, K., Khuller, S. (eds.) APPROX 2000. LNCS, vol. 1913, pp. 108–119. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  5. 5.
    Focardi, R., Luccio, F.L.: Cracking Bank PINs by Playing Mastermind. In: Boldi, P. (ed.) FUN 2010. LNCS, vol. 6099, pp. 202–213. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  6. 6.
    Goodrich, M.T.: On the algorithmic complexity of the Mastermind game with black-peg results. Information Processing Letters 109, 675–678 (2009)MathSciNetMATHCrossRefGoogle Scholar
  7. 7.
    Kalisker, 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
  8. 8.
    Knuth, D.E.: The computer as Master Mind. Journal of Recreational Mathematics 9, 1–6 (1976-1977)Google Scholar
  9. 9.
    Papadimitriou, C.H.: Computational complexity. Addison-Wesley Publishing Company, Inc. (1994)Google Scholar
  10. 10.
    Stuckman, J., Zhang, G.-Q.: Mastermind is NP-complete. INFOCOMP Journal of Computer Science 5, 25–28 (2006)Google Scholar
  11. 11.
    Valiant, L.G.: The complexity of computing the permanent. Theoretical Computer Science 8, 189–201 (1979)MathSciNetMATHCrossRefGoogle Scholar
  12. 12.
    Valiant, L.G.: The complexity of enumeration and reliability problems. SIAM Journal on Computing 8, 410–421 (1979)MathSciNetMATHCrossRefGoogle Scholar
  13. 13.
    Valiant, L.G., Vazirani, V.V.: NP is as easy as detecting unique solutions. Theoretical Computer Science 47, 85–93 (1986)MathSciNetMATHCrossRefGoogle Scholar
  14. 14.
    Yato, T.: Complexity and completeness of finding another solution and its application to puzzles. Master’s thesis, University of Tokyo (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Giovanni Viglietta
    • 1
  1. 1.University of PisaItaly

Personalised recommendations