Comments (17)
Computers were so slow that one couldn't consider every word in the dictionary as a potential guess. He decided empirically on a sample size that played well enough.
I became a mathematician. From this childhood exposure, entropy was the first mathematical "concept" beyond arithmetic that I understood.
(I mention this so people will know the list exists, and hopefully email us more nominations when they see an unusually great and interesting comment, like this one.)
Very cool.
By then I was in college with some of my high school buddies when one of them got the original board game. These were not actually that common even among those who liked thinking games since they were about $10, for $1 worth of plastic. And the box was way small compared to the full-size popular board games which were about $5.
It was quite interesting that there were diverse international people pictured on the cover and it didn't take long to realize this was a game where no players need to speak the same language at all.
By the time I got my Atari computer, this was the only game I ever coded since it's absolutely perfect to play having the computer in the role of "codemaker". I had never seen or heard of a computer mouse but I had my trackball for playing Centipedes and Missle Command so used it to point & click, then before I was done I was dragging & dropping the colors from their repository to the hot spots. I was simulating picking & placing like the board game.
Eventually I used two columns so two players could play against the Atari simultaneously, each with their own trackball or joystick. Since it was always basically a "one-player" game doing the solving, then two people could solve at once. I was going to suggest trying it that way next time but I don't know if it's as straightforward to use two mice and associate one with each player.
My strategy was simulate my possible next guesses against all possible codes, then pick the option that had the highest number of possible outcomes (sometimes this strategy is called MaxParts). It looks like the author's approach works for similar underlying reasons.
Besides this, I applied some optimizations for the starting move, and some further optimizations on considering 'irrational' guesses -- e.g. choosing a code that had already been eliminated as a possibility, because it returned more information (this was rare, but possible).
I ran my code against all possible games of 4,6 mastermind (I win in an average of 4.2778 guesses), and found that some starting guesses were more optimal than others! The pattern "AABC" (e.g. red-red-yellow-green) was the best performer. Perhaps this is a way that the author can improve their algorithm just a tiny bit.
We had some fun and nice exchange around it, but closing all parties in just 4 rounds made it quickly boring.
Weirdly, Scrabble resembles crosswords graphically but fits in the second group.
$ printf '%s\n' {a..f}{a..f}{a..f}{a..f}|head
aaaa
aaab
aaac
aaad
aaae
aaaf
aaba
aabb
aabc
aabd
$ printf '%s\n' {a..f}{a..f}{a..f}{a..f}|wc -l
1296
So say you've guessed acab and gotten two black pins, then you know nothing is in the right position, so you can `grep -v acab` but also that two of your pins should be used somewhere `grep -E 'a.*[cab]|c.*[ab]|b.*[ca]'` (hope I got that right?) $ printf '%s\n' {a..f}{a..f}{a..f}{a..f}|grep -v acab | grep -E 'a.*[cab]|c.*[ab]|b.*[ca]'|wc -l
756
That filters your options down.However, I don't understand how/whether grepping can give you the optimal next guesses – some of these will give you less information than others. (Of course, you could run some simulations with grep, argmaxing over all the possible responses like the article says, but then you're not just doing simple grepping.)
I believe it is provably not the optimal algorithm for solving the problem under the minimax objective, and I have a hunch that (due to rounding issues) it is also not optimal for minimizing the expected number of guesses under even a uniform prior. So what does this actually accomplish?
>We have now landed on our final strategy: start by figuring out the number of possible secret codes n. For each guess, calculate the number n_i' of codes that will still be viable if the Code Master gives response i in return. Do this for all possible responses.
But then I don't agree with:
>Finally, calculate the entropy of each guess; pick the one with the highest.
Why wouldn't we just pick argmin_{guess} sum{i in possible responses}{Pr[i] * n'_i} = sum{i in possible responses}{n'_i/n * n'_i} = sum{i in possible responses}{n'_i^2}? This is the guess that minimizes the expected size of the resulting solution space.