20 Questions Game

About

20 Questions is a guessing game in which a player tries to identify an object in 20 questions or less. The player guessing will ask a series of “yes” or “no” questions in an attempt to figure out what the user's chosen answer is. Each round of the game will begin with the human player thinking of an object. The computer will try to guess the object by asking a series of yes-or-no questions. Eventually the computer will have asked enough questions that it thinks it knows what object the user is thinking of, so it will make a final guess about what the object is. If this guess is correct, the computer wins; if not, the user wins.

The game has the following new major features:

  • The computer stores its knowledge of questions and answers in a binary tree.
  • The computer updates its question tree after each game it loses by asking the human player for a new question and answer, and therefore it gets better at the game over time.
  • The computer can save and load its tree of questions and answers from the disk so that it will retain its improvements over time, even after the program exits and reloads later.

Technologies & Concepts

  • C++
  • Binary trees
  • Tree traversal/Recursion
  • File I/O
  • Memory management