public Node SearchBestNode(Pieces.Color color) { Node best = null; GetBestNode(_root, ref best, 0, color); return(best); }
public float GetHeuristic(Pieces.Color color) { if (!_heuristic.HasValue) { _heuristic = _state.Evaluate(color); } return(_heuristic.Value); }
public void NextPlayer() { if (turn == ches.Pieces.Color.WHITE) { turn = ches.Pieces.Color.BLACK; } else { turn = ches.Pieces.Color.WHITE; } }
private void GetBestNode(Node root, ref Node best, int depth, Pieces.Color color) { var children = root.GetChildren().OrderByDescending(x => x.GetHeuristic(color)).Take(branches); var currentBest = children.FirstOrDefault(); if (currentBest != null && currentBest.GetHeuristic(color) > best.GetHeuristic(color)) { best = currentBest; } if (depth >= MAX_DEPTH) { return; } foreach (var child in children) { GetBestNode(child, ref best, depth + 1, color); } }