mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33: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:
parent
c35c18a705
commit
b7bc0d4c57
1 changed files with 55 additions and 54 deletions
|
@ -808,13 +808,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
|||
key ^= zobEp[st->epSquare];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update incremental scores
|
||||
st->value += pst_delta(piece, from, to);
|
||||
|
||||
// Set capture piece
|
||||
st->capture = capture;
|
||||
|
||||
if (pm) // promotion ?
|
||||
{
|
||||
|
@ -855,6 +848,13 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
|||
// Update material
|
||||
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
|
||||
st->key = key;
|
||||
|
@ -901,6 +901,10 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t
|
|||
|
||||
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 ?
|
||||
{
|
||||
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;
|
||||
}
|
||||
st->pawnKey ^= zobrist[them][PAWN][capsq];
|
||||
}
|
||||
else
|
||||
st->npMaterial[them] -= piece_value_midgame(capture);
|
||||
|
||||
// Remove captured piece
|
||||
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
|
||||
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
|
||||
pieceCount[them][capture]--;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue