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); }
public override string ToString(Game game) { Readable_GamePlayer player = this.playerProvider.GetValue(this.Cause, game, (Writable_GamePlayer)null); Resource bonusResources = this.resourcesToGain_provider.GetValue(this.Cause, game, (Resource)null); return(player.ToString() + " gains " + bonusResources.ToString()); }
public override string ToString(Game game) { int amountToGain = this.amountToGain_provider.GetValue(this, game, default(int)); Readable_GamePlayer controller = this.chooserProvider.GetValue(this, game, (Readable_GamePlayer)null); string result = controller.ToString(); if (amountToGain > 0) { result += " heals a target for " + amountToGain; } else { result += " damages a target for " + (amountToGain * -1); } return(result); }