3 ms·
The Knuth approach said to be implemented in this post is described in: > The computer as Master Mind. Journal of Recreational Mathematics 9 (1976), pp. 1–6. R
by svat 3y ago
The Knuth approach said to be implemented in this post is described in:
> The computer as Master Mind. Journal of Recreational Mathematics 9 (1976), pp. 1–6. Reprinted with an addendum as Chapter 25 of Selected Papers on Fun and Games.
https://www.cs.uni.edu/~wallingf/teaching/cs3530/resources/knuth-mastermind.pdf https://www.cs.uni.edu/~wallingf/teaching/cs3530/resources/k... is the original paper, but the addendum in the 2011 book is 5 pages long, longer than the original article itself (not counting its figure/table), and discusses various later results/ideas. For example, the addendum mentions that while Knuth's approach only minimizes the worst-case number of guesses (5, with 4.4753 on average), we can try to also minimize the expected number of guesses: I don't want to quote at length, but see https://stackoverflow.com/a/54917672 https://stackoverflow.com/a/54917672 and the discussion on the German Wikipedia https://de.wikipedia.org/w/index.php?title=Mastermind_(Spiel)&oldid=231513977#Strategien https://de.wikipedia.org/w/index.php?title=Mastermind_(Spiel....
In this post however, it looks like
• the scoring function is wrong, as pointed out in comment here by danbruc,
• the code in the post simply guesses at random ("It only randomly selects its next guess from a pool of possible remaining guessing"), while Knuth's approach is of "choosing at every stage a test pattern that minimizes the maximum number of remaining possibilities over all conceivable responses by the codemaker". (In fact if you run the program in the post, it takes 6 guesses to win!)