Hacker News new | ask | show | jobs
by Saigonautica 301 days ago
Oh, I loved working on this problem years back.

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.