主题
Search

Mastermind


Mastermind 是一款简单的双人破译密码棋盘游戏,由以色列邮政局长和电信专家 Mordecai Meirowitz 于 1970 年发明。它可能受到了 moo 的启发,moo 是 J. M. Grochow 于 1960 年代后期在麻省理工学院开发的一个程序。

在游戏中,一名玩家是密码制定者,另一名玩家是密码破译者。密码制定者秘密选择一个由四个颜色组成的有序序列 (c_1,c_2,c_3,c_4),每个颜色从六种可能的颜色集中选择,允许重复。然后,密码破译者尝试通过重复提出颜色序列 (g_1,g_2,g_3,g_4) 来猜测密码。每次猜测后,密码制定者会告诉密码破译者两个数字 (b,w):正确颜色且位置也正确的数量 (b) 和颜色正确但位置不正确的数量 (w)。例如,如果密码是 (1,2,3,3),密码破译者的猜测是 (3,2,4,3),那么密码制定者的回应将是 (2,1),因为密码破译者猜对了 2 和第二个 3,位置也正确,同时猜对了第一个 3,但位置不正确。

密码破译者继续猜测,直到他正确猜出密码,或者直到他达到最大允许猜测次数而没有正确识别出秘密密码。

有趣的是,w 可以计算为

 w=(sum_(i=1)^6min(c_i,g_i))-b,

其中 c_i 是颜色 i 在密码中出现的次数,g_i 是它在猜测中出现的次数。

Knuth (1976-77) 表明,密码破译者总是可以在五步或更少的步数内成功 (即,在四次猜测后知道密码)。他的技术使用了一种贪婪策略,该策略最大限度地减少了每一步剩余可能性的数量,并且平均需要 4.478 次猜测,假设代码选择的可能性均等。Irving (1978-79) 随后发现了一种平均长度稍小的策略。Koyama 和 Lai (1993) 描述了一种使平均猜测次数最小化的策略,平均需要 4.340 次猜测,尽管在最坏的情况下可能需要多达六次。Koyama 和 Lai (1993) 描述的稍作修改的策略将平均值增加到 4.341,但将所需的最大猜测次数减少到五次。

“静态” 问题,即在游戏开始时一次性找到密码破译者可以进行的最少猜测次数,而无需等待答案,然后在收到答案后,在下一次“猜测”中完全确定密码 (Chvatal 1983),可以用六次初始猜测来解决 (Greenwell 1999-2000)。一种特定的组合,允许密码破译者在六次猜测后知道密码 (因此需要第七次来揭示他对解决方案的了解) 是 (1, 2, 2, 1), (2, 3, 5, 4), (3, 3, 1, 1), (4, 5, 2, 4), (5, 6, 5, 6), (6, 6, 4, 3)。目前尚不清楚这个数字是否可以减少到五次 (穷举检查将需要 6^(5×4)=6^(20) approx 3.7×10^(15) 次计算),尽管人们认为不能。

Swaszek (1999-2000) 分析了不需要复杂的记录或使用计算机的实用策略。从剩余的候选代码序列集中随机猜测可以得出令人惊讶的短平均游戏长度 4.638,而将每次猜测解释为一个数字并使用与已知信息一致的下一个更高的数字,则游戏的平均长度为 4.758。


使用 Wolfram|Alpha 探索

参考文献

Bewersdorff, J. "Mastermind: Playing It Safe." Ch. 32 in 运气、逻辑与白色谎言:游戏数学。 Wellesley, MA: A K Peters, pp. 344-352, 2005.Bogomolny, A. and Greenwell, D. "Cut the Knot: Invitation to Mastermind." http://www.maa.org/editorial/knot/Mastermind.html.Chvatal, V. "Mastermind." Combinatorica 3, 325-329, 1983.Cole, T. "Investigations into the Master Mind Board Game: Break the Hidden Code." Feb. 5, 1999. http://www.tnelson.demon.co.uk/mastermind/.Erdős, P. and C. Rényi, C. "On Two Problems in Information Theory." Magyar Tud. Akad. Mat. Kut. Int. Közl. 8, 229-242, 1963.Flood, M. M. "Mastermind Strategy." J. Recr. Math. 18, 194-202, 1985-86.Flood, M. M. "Sequential Search Strategies with Mastermind Variants." J. Recr. Math. 20, 105-126 and 168-181, 1988.Greenwell, D. L. "Mastermind." J. Recr. Math. 30, 191-192, 1999-2000.Greenwell, D. L. "Mastermind." http://www.math.eku.edu/greenwell/MMTALK/.Greenwell, D. L. "Invitation to Mastermind." http://www.math.eku.edu/greenwell/MMTALK/MastermindTalkS5.html.Guy, R. "The Strong Law of Small Numbers." In 数学轻松一面 (Ed. R. K. Guy and R. E. Woodrow). Washington, DC: Math. Assoc. Amer., 1994.Irving, R. W. "Towards an Optimum Mastermind Strategy." J. Recr. Math. 11, 81-87, 1978-79.Knuth, D. E. "The Computer as a Master Mind." J. Recr. Math. 9, 1-6, 1976-77.Koyama, K. and Lai, T. W. "An Optimal Mastermind Strategy." J. Recr. Math. 25, 251-256, 1993.Mitchell, M. "MasterMind® Mathematics." Key Curriculum Press, 1999.Neuwirth, E. "Some Strategies for Mastermind." Z. für Operations Research 26, B257-B278, 1982.O'Geran, J. H.; Wynn, H. P.; and Zhigljavsky, A. A. "Mastermind as a Test-Bed for Search Algorithms." Chance 6, 31-37, 1993.Swaszek, P. F. "The Mastermind Novice." J. Recr. Math. 30, 193-198, 1999-2000.Temporel, A. "MSc Project: Stochastic Search Methods in Mastermind Game." http://www.cs.bris.ac.uk/~at1691/LittReview.html.Viaud, D. "Une stratégie générale pour jouer au Master-Mind." RAIRO Recherche opérationelle/Operations Research 21, 87-100, 1987.

在 Wolfram|Alpha 中引用

Mastermind

引用为

Weisstein, Eric W. "Mastermind." 来自 MathWorld--Wolfram Web 资源。 https://mathworld.net.cn/Mastermind.html

主题分类