by cyode · 4y ago · 0 comments
The author quips that "twenty questions isn’t enough to guess almost anything", but I wonder if most people taking their first crack at the game (usually as children) pick something squarely in the 2^20 most popular things.
(My friend's dad was really good at picking words. I remember he stumped us for an entire restaurant visit with "the cub in the Chicago Cubs logo".)
• Choose some reasonable number of questions of the form "Is it ___"?. Let's say 256
• Come up with a list of objects, and for each one give it a 256-long bitvector encoding its answers to the questions
• Maintain a set (implemented as another bitvector) of the potential items. Figure out which question would divide the set in two most closely; ask that question.
I am the opposite of a hardware hacker or systems programmer, but it seems like this is algorithmically straightforward to implement with bit-twiddling.
Actually programming the logic once you know it is the easy bit, it's constructing the dataset of answers and questions in the first place.
This depends on the goal. One goal might be to answer all questions as quickly as possible, in which case partitioning the search space in two might be a good strategy. Another goal might be to have the best chance of guessing the item within 20 questions, in which case you will want to choose questions which maximise the % of the remaining search space you can uniqely identify with the remaining questions (perhaps weighted by popularity of that item).
It's a neural net, so very efficient on small devices.