public override PlayerTask GetMove(POGame poGame) { var player = poGame.CurrentPlayer; // Implement a simple Mulligan Rule if (player.MulliganState == Mulligan.INPUT) { List <int> mulligan = new ControlScore().MulliganRule().Invoke(player.Choice.Choices.Select(p => poGame.getGame().IdEntityDic[p]).ToList()); return(ChooseTask.Mulligan(player, mulligan)); } // Apply MCTS and do the best move PlayerTask action = null; try { if (mcts) { action = MCTS(poGame.getCopy()); } else { var legalMoves = poGame.Simulate(player.Options()).Where(x => x.Value != null); return(legalMoves.Any() ? legalMoves.OrderBy(x => Score(x.Value, player.PlayerId)).Last().Key : player.Options().First(x => x.PlayerTaskType == PlayerTaskType.END_TURN)); } } catch (NullReferenceException) { action = player.Options().First(x => x.PlayerTaskType == PlayerTaskType.END_TURN); } if (myDebug) { Console.WriteLine(); Console.WriteLine(poGame.FullPrint()); Console.WriteLine("Chose action: " + action); } return(action); }