public GameEffect ChooseBestAction(GameChoice choice, Game game) { game = game.Clone(); // Inform the game and its descendents that it is a hypothetical game, so all players use the strategy of the player doing the imagining Readable_GamePlayer chooser = game.Get_ReadableSnapshot(choice.ControllerID); game.Strategy = game.GetStrategy(chooser); IEnumerable <GameEffect> effects = choice.Options; // create the base game Analyzed_GameState rootState = new Analyzed_GameState(game, null, null, this.GameEvaluator.EstimateWinProbabilities(game)); rootState.ChoosingPlayerID = choice.ControllerID; // Put the first set of choices onto the starting gameState this.PutGameOptions(rootState, choice); // loop until we run out of time while (rootState.NumDescendents < this.NumTimeSteps) { // Find the current best path and explore it for one more time unit this.ProcessOnce(rootState); double winProbability = rootState.WinProbabilities[choice.ControllerID]; if (winProbability == 0 || winProbability == 1) { break; } } if (this.ShouldPrint) { Console.WriteLine("Plan for " + chooser.ToString()); rootState.printBestPath(); } return(rootState.FavoriteChild.SourceEffect); }