struct ReducedStateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
- Square kingSquare[2], epSquare;
+ Square epSquare;
Value mgValue, egValue;
Value npMaterial[2];
};
board[to] = board[from];
board[from] = EMPTY;
- // If the moving piece was a king, update the king square
- if (pt == KING)
- st->kingSquare[us] = to;
-
// Update piece lists, note that index[from] is not updated and
// becomes stale. This works as long as index[] is accessed just
// by known occupied squares.
Square lastPawnSquare = pieceList[us][PAWN][pieceCount[us][PAWN]];
index[lastPawnSquare] = index[to];
pieceList[us][PAWN][index[lastPawnSquare]] = lastPawnSquare;
+ pieceList[us][PAWN][pieceCount[us][PAWN]] = SQ_NONE;
index[to] = pieceCount[us][promotion] - 1;
pieceList[us][promotion][index[to]] = to;
Square lastPieceSquare = pieceList[them][capture][pieceCount[them][capture]];
index[lastPieceSquare] = index[capsq];
pieceList[them][capture][index[lastPieceSquare]] = lastPieceSquare;
+ pieceList[them][capture][pieceCount[them][capture]] = SQ_NONE;
// Reset rule 50 counter
st->rule50 = 0;
board[kto] = king;
board[rto] = rook;
- // Update king square
- st->kingSquare[us] = kto;
-
// Update piece lists
pieceList[us][KING][index[kfrom]] = kto;
pieceList[us][ROOK][index[rfrom]] = rto;
Square lastPromotionSquare = pieceList[us][promotion][pieceCount[us][promotion]];
index[lastPromotionSquare] = index[to];
pieceList[us][promotion][index[lastPromotionSquare]] = lastPromotionSquare;
+ pieceList[us][promotion][pieceCount[us][promotion]] = SQ_NONE;
index[to] = pieceCount[us][PAWN] - 1;
pieceList[us][PAWN][index[to]] = to;
}
0, 0
};
- Bitboard attackers, stmAttackers, occ, b;
+ Bitboard attackers, stmAttackers, b;
assert(square_is_ok(from) || from == SQ_NONE);
assert(square_is_ok(to));
// Initialize pieces
Piece piece = piece_on(from);
Piece capture = piece_on(to);
-
- // Find all attackers to the destination square, with the moving piece
- // removed, but possibly an X-ray attacker added behind it.
- occ = occupied_squares();
+ Bitboard occ = occupied_squares();
// Handle en passant moves
if (st->epSquare == to && type_of_piece_on(from) == PAWN)
while (true)
{
+ // Find all attackers to the destination square, with the moving piece
+ // removed, but possibly an X-ray attacker added behind it.
clear_bit(&occ, from);
attackers = (rook_attacks_bb(to, occ) & pieces(ROOK, QUEEN))
| (bishop_attacks_bb(to, occ) & pieces(BISHOP, QUEEN))
set_bit(&byTypeBB[0], s); // HACK: byTypeBB[0] contains all occupied squares.
pieceCount[c][pt]++;
-
- if (pt == KING)
- st->kingSquare[c] = s;
}