mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-16 23:26:23 +08:00
Micro optimization of generate_piece_moves()
This patch make the piece list always terminated by SQ_NONE, so that we can use a simpler and faster loop in move generation. Speedup is about 0.6%. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -838,6 +838,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||
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;
|
||||
|
||||
@@ -943,6 +944,7 @@ void Position::do_capture_move(Bitboard& key, PieceType capture, Color them, Squ
|
||||
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;
|
||||
@@ -1099,6 +1101,7 @@ void Position::undo_move(Move m) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user