Essential insights from Hacker News discussions

Using information theory to solve Mastermind

This Hacker News discussion revolves around the game Mastermind (and its relation to other puzzle games like Wordle) and the strategies for playing it, with a significant focus on information theory and computational approaches.

Appreciation for Puzzle Solving and Cognitive Engagement

Many users expressed a deep appreciation for the intellectual challenge and satisfaction derived from solving puzzles like Mastermind. The process of finding optimal or near-optimal strategies is described as mentally stimulating and rewarding.

  • "I love stuff like this. It always tickles my brain to try and find the optimal way (or, as optimal a way as I can) of solving puzzles. Sometimes it's easy, sometimes it's really hard. Oftentimes you can get something decent with not too much effort, and the dopamine hit is great when you see it working" - rokkamokka
  • "Really great article. Internalizing that a good realizable Mastermind strategy is to always eliminate the same number of possible solutions is a great way to internalize the value of information theory thinking." - jmount
  • "It hurt my brain but in a good way. I think a lot of my problem solving and interest in coding stemmed from it." - mrbluecoat
  • "Had the same experience. I loved playing with my mom, and I remember spending a lot of time thinking about how to optimize my guesses. It fit all my hobbies around logic." - cortesoft

Parallels Between Mastermind and Wordle, and Broader Game Classification

A recurring theme is the comparison of Mastermind to Wordle, with users noting that Wordle shares more characteristics with Mastermind than with traditional word games. This leads to discussions about what defines different types of word or logic puzzles.

  • "But a friend of mine made the very astute observation that Wordle is more like Mastermind (which I played and even wrote a Windows version of as an exercise once upon a time) than any traditional word game." - ghaff
  • "I think you can distinguish between word games where it helps to know what the words mean (like crosswords) and word games where the meaning of the words is irrelevant, only that they are or are not words (like Wordle)." - madcaptenor
  • "Although I must say I do like Connections where even subtle meaning very much factors in." - ghaff
  • "Sudoku is kind of the same, in that the numerical values of the numbers doesn't come into play at all. You can replace the digits with fruits and the game plays the same." - yen223

The Role of Information Theory and Entropy

Several users highlight the connection between Mastermind's optimal play and information theory, particularly the concept of entropy. The goal is often framed as maximizing the information gained from each guess to reduce the uncertainty about the secret code.

  • "From this childhood exposure, entropy was the first mathematical 'concept' beyond arithmetic that I understood." - Syzygies
  • "I don't know if you need 'information theory' to do something that can be solved with grep." - CyberDildonics
  • "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. Finally, calculate the entropy of each guess; pick the one with the highest." - (Quoting the article's strategy, which was then discussed)
  • "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." - nsomani

Algorithmic Approaches and Computational Strategy

The discussion delves into the computational aspects of solving Mastermind, including algorithmic strategies, starting moves, and the capabilities of AI.

  • "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." - Saigonautica
  • "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." - Saigonautica
  • "Each constraint given to you by the game can be done in grep and used to filter a master list of all the answers by piping the filtered list through each constraint." - CyberDildonics
  • "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." - CaptainNegative
  • "I noticed that Claude, ChatGPT, and DeepSeek - none of those LLMs can solve Mastermind. They get lost after a few iterations, no matter how good the prompt instructions are." - mqtx

Nostalgia and Personal Connections to the Game

Several users share personal anecdotes and memories associated with playing Mastermind, often from childhood or during formative years, highlighting its impact on their development and relationships.

  • "I grew up with this game. It hurt my brain but in a good way. I think a lot of my problem solving and interest in coding stemmed from it." - mrbluecoat
  • "I love playing with my mom, and I remember spending a lot of time thinking about how to optimize my guesses." - cortesoft
  • "The Kodak Research Labs (like Bell Labs) let their researchers play. In the 1960's my father (who later devised the Bayer filter for digital cameras) coded this algorithm for 'Jotto' the 5 letter word version of Mastermind." - Syzygies
  • "This was my favorite game to play with my parents when I was growing up." - m-hodges
  • "My grade school had a game club at lunch hour. Mr. Newton took time out of his day, every day for us. Still think about him and the many games he brought from his had personal collection." - bethekidyouwant

Typographical Observations and Minor Corrections

A minor but noticeable theme is the correction of a specific typo in the article ("Worldle" instead of "Wordle") and related discussions about online games.

  • "Tiny tip, 'Worlde' is obviously a typo for the popular puzzle." - cwmoore
  • "tho typo so obvious that it became a thing https://worldle.teuteuf.fr/" - NooneAtAll3