/// <summary> /// Simulates a playout from the current node. /// </summary> /// <param name="id">The current node's ID.</param> /// <returns>Whether the playout was won or lost.</returns> public bool Simulate(int id) { // Read the node's object from disk. GameTreeNode node = GetNode(id); // Iterate the total plays. totalPlays++; // Initialize a dead end check. bool check = false; // If the node is not a dead end before it is played, we need to check. if (!node.DeadEnd) { check = true; } // Play a game and store the result. bool result = node.Play(); // Store a win. if (result) { totalWins++; } // Otherwise, store a loss. else { totalLosses++; } // If we found a new dead end, record it. if (check && node.DeadEnd) { deadEndCount++; } // Save the node to disk. SetNode(node); // Return the result. return(result); }