20 Questions

technology games

An app that plays 20 questions with you. You can think of a noun and then it will ask you yes or no questions to see if it can figure out what you’re thinking of within 20 questions.

I was thinking about how this might be implemented and I think it might go something like this:

  1. Get a CSV file of an english dictionary and filter it down to just the nouns
  2. Brainstorm a list of questions (maybe like 100 or so?). Questions like “is it alive?”, “can you eat it?”, etc…
  3. Combine each noun with each question and run it through an API like ChatGPT so that you get a large matrix or nouns and yes or no classifications for each question
  4. As the game progresses, the algorithm determines which question will divide the results roughly in half and that’s how it determines what to ask.
  5. If it was narrowed down to a single item, that would be the guess. Otherwise, at the end of the 20 questions, it would guess whichever item has the highest probability (maybe with a metric from the dictionary around how common the word was?)

Through a quick search, there are maybe about 80,000 nouns in English. So, if you kept divinding it in half at each question, it should always be able to guess the right answer in around 16-17 questions.