public static RandomOutcomeSearch Build(Game Game, Action Action, ITreeActionWalker SearchMode = null) { var tree = new RandomOutcomeSearch(Game, SearchMode); tree.Run(Action); return(tree); }
public RandomOutcomeSearch(Game Root, ITreeActionWalker SearchMode = null, bool?Parallel = null) : base(new ProbabilisticGameNode(Root, TrackChildren: false)) { this.Parallel = Parallel ?? Settings.ParallelTreeSearch; if (SearchMode == null) { SearchMode = new BreadthFirstActionWalker(); } if (this.Parallel) { RootNode.Game.ActionQueue.ReplaceAction <RandomChoice>(replaceRandomChoiceParallel); RootNode.Game.ActionQueue.ReplaceAction <RandomAmount>(replaceRandomAmountParallel); } else { RootNode.Game.ActionQueue.ReplaceAction <RandomChoice>(replaceRandomChoice); RootNode.Game.ActionQueue.ReplaceAction <RandomAmount>(replaceRandomAmount); } RootNode.Game.ActionQueue.OnAction += (o, e) => { searcher.PostAction(o as ActionQueue, this, e); }; searcher = SearchMode; }
private Dictionary <Game, double> _search(Game game, ITreeActionWalker searcher, TestAction testAction) { return(RandomOutcomeSearch.Find( Game: game, SearchMode: searcher, Action: () => { // This is the action that shall be taken to build the tree switch (testAction) { case TestAction.BoomBot: game.CurrentPlayer.Board.First(t => t.Card.Id == "GVG_110t").Hit(1); break; case TestAction.ArcaneMissiles: game.CurrentPlayer.Hand.First(t => t.Card.Name == "Arcane Missiles").Play(); break; } } )); }
public static async Task <RandomOutcomeSearch> BuildAsync(Game Game, Action Action, ITreeActionWalker SearchMode = null) { var tree = new RandomOutcomeSearch(Game, SearchMode); await tree.RunAsync(Action); return(tree); }
public static async Task <Dictionary <Game, double> > FindAsync(Game Game, Action Action, ITreeActionWalker SearchMode = null) { var tree = await BuildAsync(Game, Action, SearchMode); return(tree.GetUniqueGames()); }
public static Dictionary <Game, double> Find(Game Game, Action Action, ITreeActionWalker SearchMode = null) { return(Build(Game, Action, SearchMode).GetUniqueGames()); }