Пример #1
0
        /// <summary>
        /// Gets the list pf PV nodes for the specified bitboard and color. Nodes count is limited by
        /// <see cref="AIConstants.MaxDepth"/> value to avoid infinite repetitions.
        /// </summary>
        /// <param name="bitboard">The initial bitboard.</param>
        /// <param name="color">The initial color.</param>
        /// <returns>The list of PV nodes.</returns>
        private PVNodesList GetPVNodes(Bitboard bitboard, Color color)
        {
            var pvNodes   = new PVNodesList();
            var boardHash = bitboard.GetHashForColor(color);

            while (_transpositionTable.Exists(boardHash) && pvNodes.Count < AIConstants.MaxDepth)
            {
                var pvNode = _transpositionTable.Get(boardHash);

                if (pvNode.BestMove == null)
                {
                    break;
                }

                pvNodes.Add(pvNode.BestMove);
                bitboard = bitboard.Move(pvNode.BestMove);

                color     = ColorOperations.Invert(color);
                boardHash = bitboard.GetHashForColor(color);
            }

            return(pvNodes);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AIResult"/> class.
 /// </summary>
 public AIResult()
 {
     Stats   = new AIStats();
     PVNodes = new PVNodesList();
 }