Example #1
0
        private void RemovePiece(int ix, Color color, PieceType pieceType)
        {
            Debug.Assert(_squares[ix] == new Piece(color, pieceType));
            _pieceBitboards[PieceBitboardIndex(color, pieceType)] &= ~ValueFromIx(ix);
            _squares[ix] = Piece.None;

            ZobristHash ^= ZobristHashing.CalculatePieceBitboardHashDiff(ValueFromIx(ix), color, pieceType);
            // TODO: material hash update
            // TODO: pawn hash update
        }
Example #2
0
        private void MovePiece(int srcIx, int dstIx, Color color, PieceType pieceType)
        {
            Debug.Assert(_squares[srcIx] == new Piece(color, pieceType));
            Debug.Assert(_squares[dstIx].PieceType == PieceType.None);
            _pieceBitboards[PieceBitboardIndex(color, pieceType)] &= ~ValueFromIx(srcIx);
            _pieceBitboards[PieceBitboardIndex(color, pieceType)] |= ValueFromIx(dstIx);
            _squares[srcIx] = Piece.None;
            _squares[dstIx] = new Piece(color, pieceType);

            ZobristHash ^= ZobristHashing.CalculatePieceBitboardHashDiff(
                ValueFromIx(srcIx) | ValueFromIx(dstIx),
                color,
                pieceType);
            // No material hash update needed
            // TODO: pawn hash update
        }