Esempio n. 1
0
        public Node SearchBestNode(Pieces.Color color)
        {
            Node best = null;

            GetBestNode(_root, ref best, 0, color);
            return(best);
        }
Esempio n. 2
0
 public float GetHeuristic(Pieces.Color color)
 {
     if (!_heuristic.HasValue)
     {
         _heuristic = _state.Evaluate(color);
     }
     return(_heuristic.Value);
 }
Esempio n. 3
0
 public void NextPlayer()
 {
     if (turn == ches.Pieces.Color.WHITE)
     {
         turn = ches.Pieces.Color.BLACK;
     }
     else
     {
         turn = ches.Pieces.Color.WHITE;
     }
 }
Esempio n. 4
0
        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);
            }
        }