public void MCTSSearchTest() { MCTS.Search(10, tree); BinarySerializer.SerializeObject <GameTree>(Parser.GetTopDirectory() + @"GameTrees\Data\Unit-Tests\gametree", tree); Assert.AreEqual(tree.Root.Unplayed.Count, 0); }
// Creates a single tree of specified depth without specifying a folder name. public static void MCTSearch(string domainName, int totalPlays, int interval) { // Save the summaries of each build. List <List <Tuple <String, String> > > summaries = new List <List <Tuple <String, String> > >(); // Remember a time stamp for the top directory. string timeStamp = DateTime.Now.ToString("MM-dd-yyyy-HH-mm-tt"); // Read in the domain file. Domain domain = Parser.GetDomain(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\domain.pddl", PlanType.StateSpace); // Read in the problem file. Problem problem = Parser.GetProblemWithTypes(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\prob01.pddl", domain); // Create a stopwatch object. Stopwatch watch = new Stopwatch(); // Remember the game tree path. string path = Parser.GetTopDirectory() + @"GameTrees\Data\" + domainName + @"\"; // Check each path to see if it exists. If not, create the folder. if (!File.Exists(path)) { Directory.CreateDirectory(path); } // Start the stopwatch. watch.Start(); // Initialize the game tree. GameTree tree = null; if (File.Exists(path + "gametree")) { tree = BinarySerializer.DeSerializeObject <GameTree>(path + "gametree"); } else { tree = new GameTree(domain, problem, path); } // Stop the stopwatch. watch.Stop(); // Loop through the depths. for (int plays = 0; plays < totalPlays; plays = plays + interval) { Console.Out.WriteLine("Starting play " + plays); // Print the current tree. summaries.Add(WriteTree(domainName, timeStamp, plays, watch, tree, false)); // Start the watch. watch.Start(); // Play the next round. MCTS.Search(interval, tree); // Save the game tree. BinarySerializer.SerializeObject <GameTree>(path + "gametree", tree); // Stop the watch. watch.Stop(); } Console.Out.WriteLine("Printing tree."); // Print the current tree. summaries.Add(WriteTree(domainName, timeStamp, totalPlays, watch, tree, false)); // Write the summary CSV file to disk. WriteGTSummary(domainName, timeStamp, summaries); // Use the CSV file to create an Excel spreadsheet and graphs of each summary element. Grapher.CreateGTGraphs(domainName, timeStamp, (totalPlays / interval) + 2, summaries); }