var moves = tree.ContainsKey(board.Key) ? tree[board.Key] : new Dictionary<int, Tuple<GameMove, MoveStats>>();
var possibleMoves = moves.Select(kvp => Tuple.Create(kvp.Key, kvp.Value.Item1, kvp.Value.Item2.Worth())).OrderByDescending(pr => pr.Item3);
if (possibleMoves.Count() == 0)
return GameMove.Random(board, Game.MoveFromPlayer(player));
if (best)
//possible moves
return possibleMoves.First().Item2;
else
{
int pos = rng.Next(possibleMoves.Count());
return possibleMoves.ElementAt(pos).Item2;
}
//return GameMove.Random(board, Game.MoveFromPlayer(player));
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.