mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 08:13:08 +00:00
Call apply_weight() only once in passed pawns evaluation
First accumulate the bonus for each pawn, then call the not very fast apply_weight(). Should be no functional change apart from rounding issues. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
17d820e248
commit
00469d1798
1 changed files with 9 additions and 5 deletions
|
@ -727,11 +727,14 @@ namespace {
|
||||||
|
|
||||||
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||||
|
|
||||||
|
Score bonus = SCORE_ZERO;
|
||||||
Bitboard squaresToQueen, defendedSquares, unsafeSquares, supportingPawns;
|
Bitboard squaresToQueen, defendedSquares, unsafeSquares, supportingPawns;
|
||||||
Bitboard b = ei.pi->passed_pawns(Us);
|
Bitboard b = ei.pi->passed_pawns(Us);
|
||||||
|
|
||||||
while (b)
|
if (!b)
|
||||||
{
|
return;
|
||||||
|
|
||||||
|
do {
|
||||||
Square s = pop_1st_bit(&b);
|
Square s = pop_1st_bit(&b);
|
||||||
|
|
||||||
assert(pos.pawn_is_passed(Us, s));
|
assert(pos.pawn_is_passed(Us, s));
|
||||||
|
@ -806,11 +809,12 @@ namespace {
|
||||||
else if (pos.pieces(ROOK, QUEEN, Them))
|
else if (pos.pieces(ROOK, QUEEN, Them))
|
||||||
ebonus -= ebonus / 4;
|
ebonus -= ebonus / 4;
|
||||||
}
|
}
|
||||||
|
bonus += make_score(mbonus, ebonus);
|
||||||
|
|
||||||
// Add the scores for this pawn to the middle game and endgame eval
|
} while (b);
|
||||||
ei.value += Sign[Us] * apply_weight(make_score(mbonus, ebonus), Weights[PassedPawns]);
|
|
||||||
|
|
||||||
} // while
|
// Add the scores to the middle game and endgame eval
|
||||||
|
ei.value += Sign[Us] * apply_weight(bonus, Weights[PassedPawns]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue