Skip to main content

Nash Equilibrium in Mastermind

  • Conference paper
  • First Online:
Book cover Computers and Games (CG 2016)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10068))

Included in the following conference series:

Abstract

Mastermind is a famous two-player deduction game. A Codemaker chooses a secret code and a Codebreaker tries to guess this secret code in as few guesses as possible, with feedback information after each guess. Many existing works have computed optimal worst-case and average-case strategies of the Codebreaker, assuming that the Codemaker chooses the secret code uniformly at random. However, the Codemaker can freely choose any distribution probability on the secret codes. An optimal strategy in this more general setting is known as a Nash Equilibrium. In this research, we compute such a Nash Equilibrium for all instances of Mastermind up to the most classical instance of 4 pegs and 6 colors, showing that the uniform distribution is not always the best choice for the Codemaker. We also show the direct relation between Nash Equilibrium computations and computations of worst-case and average-case strategies.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The straightforward proof is left to the reader.

  2. 2.

    We use (bw) since the original game use black and white pins to display the grade.

  3. 3.

    A unicolor (resp. bicolor) code is a code with both pegs with same (resp. different) color. There are 3 unicolor codes and 6 bicolor codes. Note that \(3\times \frac{1}{6}+6\times \frac{1}{12}=1\).

  4. 4.

    This formula is incorrect when \(k=1\) since there exists a single code, hence a single possible grade (n, 0). For \(k=2\) colors, there are also some unreachable grades such as \((b,w)=(0,n)\) when n is odd.

  5. 5.

    To compute WC and AVG, it is sufficient to consider only pure strategies. However for NE, it is required to consider also mixed strategies.

  6. 6.

    Pure strategies of the Codemaker are trivially computed. There are exactly \(k^n\) pure strategies, one for each possible code.

  7. 7.

    Figures 2, 3, 4 and 5 appear only in Appendix A.

  8. 8.

    A full description will be given in a longer version of this article.

  9. 9.

    Fortunately, \(4\times 0 + 48\times \frac{2}{345} + 36\times \frac{1}{276} + 144\times \frac{1}{276} + 24\times \frac{1}{345}=1\).

  10. 10.

    We could not prove yet the uniqueness for instances (5, 3), (4, 5), and (4, 6), but it should be obtained very soon.

References

  1. Chen, S.T., Lin, S.S.: Optimal algorithms for \(2\times n\) mastermind games-a graph-partition approach. Comput. J. 47, 602–611 (2004)

    Article  Google Scholar 

  2. Chvátal, V.: Mastermind. Combinatorica 3, 325–329 (1983)

    Article  MathSciNet  MATH  Google Scholar 

  3. Doerr, B., Sphel, R., Thomas, H., Winzen, C.: Playing mastermind with many colors. In: Proceedings of the 24th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 695–704 (2013)

    Google Scholar 

  4. Goddard, W.: Static mastermind. J. Comb. Math. Comb. Comput. 47, 225–236 (2003)

    MathSciNet  MATH  Google Scholar 

  5. Goddard, W.: Mastermind revisited. J. Comb. Math. Comb. Comput. 51, 215–220 (2004)

    MathSciNet  MATH  Google Scholar 

  6. Goodrich, M.T.: On the algorithmic complexity of the mastermind game with black-peg results. Inform. Process. Lett. 109, 675–678 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  7. Jäger, G., Peczarski, M.: The number of pessimistic guesses in generalized mastermind. Inform. Process. Lett. 109, 635–641 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  8. Jäger, G., Peczarski, M.: The number of pessimistic guesses in generalized black-peg mastermind. Inform. Process. Lett. 111, 933–940 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  9. Knuth, D.E.: The computer as master mind. J. Recreational Math. 9, 1–6 (1976)

    MathSciNet  MATH  Google Scholar 

  10. Koyama, K., Lai, T.: An optimal mastermind strategy. J. Recreational Math. 25, 251–256 (1993)

    MATH  Google Scholar 

  11. Nash, J.F.: Non-Cooperative Games. Ph.D. thesis, Princeton University (1950)

    Google Scholar 

  12. Pearson, K.R.: Reducing two person, zero sum games with underlying symmetry. J. Aust. Math. Soc. (Ser. A) 33, 152–161 (1982)

    Article  MathSciNet  MATH  Google Scholar 

  13. Ville, G.: An optimal mastermind \((4,7)\) strategy and more results in the expected case, May 2013, eprint arXiv:1305.1010

  14. Wiener, M.: Re: sci.math faq: Master mind, post in sci.math newsgroups on 29 Nov 1995 at 20: 44: 49

    Google Scholar 

Download references

Acknowledgments

This research was supported in part by JSPS KAKENHI Grant Number 26870228.

Author information

Authors and Affiliations

Authors

Corresponding authors

Correspondence to François Bonnet or Simon Viennot .

Editor information

Editors and Affiliations

A Example for Game Instance \((n,k)=(3,3)\)

A Example for Game Instance \((n,k)=(3,3)\)

Fig. 2.
figure 2

Exploration tree. Squared nodes correspond to grade nodes and rounded nodes to guess nodes. Grade nodes include the list of codes still possible as the secret code. Edges from a guess node to a grade node are labeled with the corresponding grade.

Fig. 3.
figure 3

Computing WC value using Min and Max operations

Fig. 4.
figure 4

Computing AVG value using Min and Sum operations

Fig. 5.
figure 5

Computing NE value using Union and MinkowskiSum operations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing AG

About this paper

Cite this paper

Bonnet, F., Viennot, S. (2016). Nash Equilibrium in Mastermind. In: Plaat, A., Kosters, W., van den Herik, J. (eds) Computers and Games. CG 2016. Lecture Notes in Computer Science(), vol 10068. Springer, Cham. https://doi.org/10.1007/978-3-319-50935-8_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-50935-8_11

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-50934-1

  • Online ISBN: 978-3-319-50935-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics