static void Main(string[] args) { //There's no need to ask for the initial data when it already exists if (File.Exists("serialized.bin")) { tree = new BTTree(); } else { startNewGame(); } //ReturnInorder(tree.rootNode); //ReturnPreOrder(tree.rootNode); //ReturnPostorder(tree.rootNode); BTNode.NodeValue(tree.rootNode); Console.WriteLine(); BTNode.MinMax(tree.rootNode); Console.WriteLine("\nStarting the \"20 Binary Questions\" Game!\nThink of an object, person or animal."); tree.query(); //play one game while (playAgain()) { Console.WriteLine("\nThink of an object, person or animal."); Console.WriteLine(); tree.query(); //play one game } }
static void Main(string[] args) { //There's no need to ask for the initial data when it already exists if (File.Exists("serialized.bin")) { tree = new BTTree(); } else { StartNewGame(); } Console.WriteLine("Output Minimax maximized: " + MiniMax(tree.GetRootNode(), true) + " (with " + calls + " calls)"); calls = 0; Console.WriteLine("Output Minimax + AB Pruning maximized: " + MiniMaxABPruning(tree.GetRootNode(), true, int.MinValue, int.MaxValue) + " (with " + calls + " calls)"); foreach (BTNode node in leafs) { Console.WriteLine(node.GetMessage()); } Console.WriteLine("\nStarting the \"20 Binary Questions\" Game!\nThink of an object, person or animal."); tree.Query(); //play one game while (PlayAgain()) { Console.WriteLine("\nThink of an object, person or animal."); Console.WriteLine(); tree.Query(); //play one game } }
static void startNewGame() { Console.WriteLine("No previous knowledge found!"); Console.WriteLine("Initializing a new game.\n"); Console.WriteLine("Enter a question about an object, person or animal: "); string question = Console.ReadLine(); Console.Write("Enter a possible guess (an object, person or animal) if the response to this question is Yes: "); string yesGuess = Console.ReadLine(); Console.Write("Enter a possible guess (an object, person or animal) if the response to this question is No: "); string noGuess = Console.ReadLine(); tree = new BTTree(question, yesGuess, noGuess); }