public override HearthNode PlayTurn(HearthNode state) { var poGame = new POGame(state.Game, false); if (!_hasInitialized) { CustomInit(poGame); } if (_isTurnBegin) { OnMyTurnBegin(poGame); } List <PlayerTask> options = poGame._game.CurrentPlayer.Options(); PlayerTask chosen = ChooseTask(poGame, options); HearthNode selected = state.Frontier.Find(h => h.Action.IsEqual(chosen)); //if (selected == null) // foreach (HearthNode p in state.PossibleActions) // { // if (p.Action.IsEqual(chosen)) // selected = p; // } //should not happen, but if, just return anything: if (selected == null) { if (TyConst.LOG_UNKNOWN_CORRECTIONS) { TyDebug.LogError("Choosen task was null!"); } selected = state.Frontier.Find(h => h.Action.IsEqual(options.GetUniformRandom(_random))); } //selected.Process(); try { state.BirthPossibility(selected); } catch (Exception) { Console.Write("Why"); } if (selected.IsEndTurn) { OnMyTurnEnd(); } return(selected); }
public override HearthNode PlayTurn(HearthNode state) { var rnd = new Random(); int rndInd = rnd.Next(state.Frontier.Count); HearthNode selected = state.Frontier[rndInd]; state.BirthPossibility(selected); //selected.Game.PowerHistory.Dump(@"C:\Users\hgore\SabberStone\core-extensions\SabberStoneCoreAi\src\Meta\SabberStone.log"); //selected.Write(filename, false, false, true); return(selected); }
/// <summary> /// Performs a MCTS to select the best action at this current game state /// </summary> /// <param name="state"></param> /// <returns></returns> HearthNode PrepAndProcessMCTS(HearthNode state) { PredictOpponentDeck(state); HearthNode MCTSNode = DontCheat(state); MCTSNode.FixMolten(); SimTree = new HearthTree(MCTSNode); HearthNode move = SimTree.MCTS(); state.BirthPossibility(move); return(move); }