private ICollection<Card> PreprocessMoves(PlayerTurnContext context, ICollection<Card> testCandidates) { var candidateMoves = new List<Card>(); var game = new GameSimulation(); foreach (var move in testCandidates) { bool gameIsWon = game.AmWinnerIfSimpleSimulateFullGame(new List<Card>(), move, this.Cards.ToList<Card>(), true, context, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints); if (gameIsWon) { candidateMoves.Add(move); return candidateMoves; } else { bool isBad = false; ////foreach (var opponentsMove in opponentMoves) ////{ //// var tmp = game.DeepClone(); //// // tmp.Move(opponentsMove); //// // did we make an assist? //// if (tmp.OppositePlayerWon()) //// { //// // forget the move! //// isBad = true; //// break; //// } ////} if (!isBad) { candidateMoves.Add(move); } } } return candidateMoves; }
private float Expand(Card move, PlayerTurnContext context) { int value = 0; var game = new GameSimulation(); for (int play = 0; play < NumberOfPlayouts; ++play) { bool gameIsWon = game.AmWinnerIfSimpleSimulateFullGame(new List<Card>(), move, this.Cards.ToList<Card>(), true, context, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints); if (gameIsWon) { value++; } else if (!gameIsWon) { value--; } else if (this.rand.Next(2) == 0) { value++; } else { value--; } } return value / (float)NumberOfPlayouts; }