public void AddChoice(GameChoice choice) { if (choice.Options.Count() == 1) { // if there's only one option, we might as well resolve it now rather than queuing up a decision to ask the player about later GameEffect effect = choice.Options.First(); effect.Process(this); } else { // If an effect creates a choice, then that choice is processed before any previous choices (like attacking or ending the turn) this.pendingEffects.AddFirst(choice); } }
public void PlayOneAction() { GameChoice choice = this.Get_NextChoice(); GameStrategy strategy = this.GetStrategy(this.Get_ReadableSnapshot(choice.ControllerID)); GameEffect effect = strategy.ChooseBestAction(choice, this); if (!(choice.Options.Contains(effect))) { Console.WriteLine("GameStrategy " + strategy + " made an invalid choice: " + effect); effect = strategy.ChooseBestAction(choice, this); } if (this.ShouldPrint) { Console.WriteLine(effect.ToString(this)); } effect.Process(this); }
private void PutGameOptions(Analyzed_GameState gameState, GameChoice choice) { if (choice.Options.Count() < 1) { Console.WriteLine("Error: a GameChoice must always have options"); } gameState.ChoosingPlayerID = choice.ControllerID; foreach (GameEffect effect in choice.Options) { // quickly do a lazy clone of the game (we just use pointers to the other game until anything actually changes) Game newGame = gameState.Game.Clone(); // make a new effect and execute it GameEffect clonedEffect = effect.Clone((GameEffect)null); clonedEffect.Process(newGame); new Analyzed_GameState(newGame, gameState, effect, this.GameEvaluator.EstimateWinProbabilities(newGame)); } }