20 Questions

20 Questions

Overview

Using a binary tree, this program reads a text file containing base information and, depending on the user answering simple yes or no questions, will guess who the user is thinking of. If the program guesses correctly, it asks the user if they would like to play again. If the program guesses incorrectly, it will ask the user who they were thinking of and what seperates the two and asks if the user would like to play again. Once the user chooses to cease playing, the new information is written to the programs text file for the next time the game is plated, thus the program "learns" the new information.

Tools and Technologies

This project was created with C# in Visual Studio 2017

Challenges

It was difficult using the FileIO StreamWriter to write all the new information to the program's text file, as each item in the text file has a "L" or "B" in front of it which denotes whether that item is a branch or leaf node. This was fixed by using a recursive function to check whether the item has children, and if it doesn't it's assigned "L" and if it does it's assigned "B".

View Code