主題
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。


使用 探索

參考文獻

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.

在 中引用

Mastermind

引用為

Weisstein, Eric W. "Mastermind." 來自 Web 資源。 https://mathworld.tw/Mastermind.html

主題分類