Skip to content

Commit bebd6e1

Browse files
R-Pelegmcostalba
authored andcommitted
Simplify unstoppable pawns evaluation
No functional change
1 parent 49e110c commit bebd6e1

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/evaluate.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,19 +1002,19 @@ Value do_evaluate(const Position& pos, Value& margin) {
10021002
{
10031003
b2 = supporters & in_front_bb(winnerSide, rank_of(blockSq + pawn_push(winnerSide)));
10041004

1005-
while (b2) // This while-loop could be replaced with LSB/MSB (depending on color)
1005+
if (b2)
10061006
{
1007-
d = square_distance(blockSq, pop_lsb(&b2)) - 2;
1007+
d = square_distance(blockSq, backmost_sq(winnerSide, b2)) - 2;
10081008
movesToGo = std::min(movesToGo, d);
10091009
}
10101010
}
10111011

10121012
// Check pawns that can be sacrificed against the blocking pawn
1013-
b2 = pawn_attack_span(winnerSide, blockSq) & candidates & ~(1ULL << s);
1013+
b2 = pawn_attack_span(winnerSide, blockSq) & candidates & ~SquareBB[s];
10141014

1015-
while (b2) // This while-loop could be replaced with LSB/MSB (depending on color)
1015+
if (b2)
10161016
{
1017-
d = square_distance(blockSq, pop_lsb(&b2)) - 2;
1017+
d = square_distance(blockSq, backmost_sq(winnerSide, b2)) - 2;
10181018
movesToGo = std::min(movesToGo, d);
10191019
}
10201020

@@ -1033,12 +1033,8 @@ Value do_evaluate(const Position& pos, Value& margin) {
10331033
kingptg = (minKingDist + blockersCount) * 2;
10341034
}
10351035

1036-
// Check if pawn sacrifice plan _may_ save the day
1037-
if (pliesToQueen[winnerSide] + 3 > pliesToGo + sacptg)
1038-
return SCORE_ZERO;
1039-
1040-
// Check if king capture plan _may_ save the day (contains some false positives)
1041-
if (pliesToQueen[winnerSide] + 3 > pliesToGo + kingptg)
1036+
// Check if pawn sacrifice or king capture plan _may_ save the day
1037+
if (pliesToQueen[winnerSide] + 3 > pliesToGo + std::min(kingptg, sacptg))
10421038
return SCORE_ZERO;
10431039
}
10441040

0 commit comments

Comments
 (0)