private void DecideMove() { double bestScore = double.MinValue; PossibleMoves = Map.PossibleMoves(); double currentScore = 0; var depth = MaxDepth; if (PossibleMoves.Count() == 1) { best = PossibleMoves.ElementAt(0); Finished = true; return; } RemoveUselessMoves(); var moves = new List <Tuple <uint, uint> >(PossibleMoves); foreach (var move in moves) { Map.Play(move.Item1, move.Item2, State.Myself); PossibleMoves.Remove(move); currentScore = MinimiseMove(depth, double.MinValue, double.MaxValue, move); if (currentScore == double.MaxValue) { PossibleMoves.Add(move); Map.Unplay(move.Item1, move.Item2); best = move; Finished = true; return; } if (best == null || bestScore < currentScore) { best = move; bestScore = currentScore; } PossibleMoves.Add(move); Map.Unplay(move.Item1, move.Item2); } Finished = true; }