Beating Mastermind: Winning with the help of Donald Knuth
summary
Implementation of Donald Knuth’s Mastermind procedure in Ruby: the code builds the Cartesian product of 1–6 four times, precomputes every guess/answer score, and runs a minimax algorithm that minimizes the maximum remaining possibilities, prefers valid codewords, and breaks ties by numeric order. The surprising claim is realized: with the 1122 initial guess and the lookup logic the program guarantees a win in five moves or less; code and notes are posted to GitHub.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 0:37What is Mastermind
- 1:47Example Game
- 5:33Donald Knuth
- 6:06The paper
- 7:12The fourth move
- 8:45The core of the paper
- 11:38How to implement the algorithm
- 19:12The code
- 19:58Basic logic
- 20:38Game structure
- 21:55Scoring
- 23:40Making guesses
- 29:35Climax
- 30:52Code
- 36:01Running the program
related talks
37mShall We Play A Game?
46mBeating Go thanks to the power of randomness
24mCracking Wordle: Machine Learning based Strategies
08mMinimax search and the structure of cognition!
25mBuilding Board Games with Ruby
33mShall We Play A Game?
33mRuby for Home-Ec
45mProblem Solved! Using Logic Programming to Find Answers
