1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Move promotion and ep under pawn handling

And remove from main do_move() flow. Just a small speedup
because we avoid two branches in the common case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-05-31 12:01:33 +01:00
parent c35c18a705
commit b7bc0d4c57

View file

@ -808,13 +808,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
key ^= zobEp[st->epSquare]; key ^= zobEp[st->epSquare];
} }
} }
}
// Update incremental scores
st->value += pst_delta(piece, from, to);
// Set capture piece
st->capture = capture;
if (pm) // promotion ? if (pm) // promotion ?
{ {
@ -855,6 +848,13 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
// Update material // Update material
st->npMaterial[us] += piece_value_midgame(promotion); st->npMaterial[us] += piece_value_midgame(promotion);
} }
}
// Update incremental scores
st->value += pst_delta(piece, from, to);
// Set capture piece
st->capture = capture;
// Update the key with the final value // Update the key with the final value
st->key = key; st->key = key;
@ -901,6 +901,10 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t
Square capsq = to; Square capsq = to;
// If the captured piece was a pawn, update pawn hash key,
// otherwise update non-pawn material.
if (capture == PAWN)
{
if (ep) // en passant ? if (ep) // en passant ?
{ {
capsq = (them == BLACK)? (to - DELTA_N) : (to - DELTA_S); capsq = (them == BLACK)? (to - DELTA_N) : (to - DELTA_S);
@ -912,6 +916,10 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t
board[capsq] = EMPTY; board[capsq] = EMPTY;
} }
st->pawnKey ^= zobrist[them][PAWN][capsq];
}
else
st->npMaterial[them] -= piece_value_midgame(capture);
// Remove captured piece // Remove captured piece
clear_bit(&(byColorBB[them]), capsq); clear_bit(&(byColorBB[them]), capsq);
@ -924,13 +932,6 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t
// Update incremental scores // Update incremental scores
st->value -= pst(them, capture, capsq); st->value -= pst(them, capture, capsq);
// If the captured piece was a pawn, update pawn hash key,
// otherwise update non-pawn material.
if (capture == PAWN)
st->pawnKey ^= zobrist[them][PAWN][capsq];
else
st->npMaterial[them] -= piece_value_midgame(capture);
// Update piece count // Update piece count
pieceCount[them][capture]--; pieceCount[them][capture]--;