How can I implement a "20 Questions" algorithm? Ever since childhood, I've wondered how the 20Q electronic game worked. You think of an object, thing, or animal (e.g. potato or donkey). The device then asks you a series of questions such as Is it larger than a loaf of bread? Is it found outdoors? Is it used for recreation? For each question, you can answer yes, no, maybe, or unknown. I always imagined it work with immense, nested conditionals (if statements). However, I think that's an unlikely explanation because of its complexity for the programmer. How would I implement such a system?