Пример #1
0
        private StandardGamePosition(
            [NotNull] PiecePosition piecePosition,
            GameSide activeSide,
            int fullMoveIndex,
            CastlingOptions castlingOptions,
            EnPassantCaptureInfo2?enPassantCaptureInfo,
            int halfMoveCountBy50MoveRule)
            : base(piecePosition, activeSide, fullMoveIndex)
        {
            if (piecePosition is null)
            {
                throw new ArgumentNullException(nameof(piecePosition));
            }

            if (halfMoveCountBy50MoveRule < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(halfMoveCountBy50MoveRule),
                          halfMoveCountBy50MoveRule,
                          @"The value cannot be negative.");
            }

            CastlingOptions           = castlingOptions;
            EnPassantCaptureInfo      = enPassantCaptureInfo;
            HalfMoveCountBy50MoveRule = halfMoveCountBy50MoveRule;

            //// TODO [HarinezumiSama] IMPORTANT: This Zobrist key algorithm is different from the one used in the Polyglot opening book (in the en-passant part)
            ZobristKey = PiecePosition.ZobristKey
                         ^ ZobristHashHelper.GetCastlingHash(CastlingOptions)
                         ^ ZobristHashHelper.GetEnPassantHash(
                EnPassantCaptureInfo,
                PiecePosition[ActiveSide.ToPiece(PieceType.Pawn)])
                         ^ ZobristHashHelper.GetTurnHash(ActiveSide);
        }