Simplify passed pawn evaluation
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 27 Jun 2020 16:42:04 +0000 (18:42 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 27 Jun 2020 16:42:04 +0000 (18:42 +0200)
No functional change.

src/evaluate.cpp

index af5b918..8ddc7c4 100644 (file)
@@ -753,7 +753,7 @@ namespace {
     constexpr Direction Up   = pawn_push(Us);
 
     auto king_proximity = [&](Color c, Square s) {
-      return pos.count<KING>(c) ? std::min(distance(pos.square<KING>(c), s), 5) : 5;
+      return pos.extinction_value() == VALUE_MATE ? 0 : pos.count<KING>(c) ? std::min(distance(pos.square<KING>(c), s), 5) : 5;
     };
 
     Bitboard b, bb, squaresToQueen, unsafeSquares;
@@ -776,17 +776,13 @@ namespace {
             int w = 5 * r - 13;
             Square blockSq = s + Up;
 
-            // Skip bonus for antichess variants
-            if (pos.extinction_value() != VALUE_MATE)
-            {
-                // Adjust bonus based on the king's proximity
-                bonus += make_score(0, (  (king_proximity(Them, blockSq) * 19) / 4
-                                         - king_proximity(Us,   blockSq) *  2) * w);
+            // Adjust bonus based on the king's proximity
+            bonus += make_score(0, ( (king_proximity(Them, blockSq) * 19) / 4
+                                    - king_proximity(Us,   blockSq) *  2) * w);
 
-                // If blockSq is not the queening square then consider also a second push
-                if (r != RANK_7)
-                    bonus -= make_score(0, king_proximity(Us, blockSq + Up) * w);
-            }
+            // If blockSq is not the queening square then consider also a second push
+            if (r != RANK_7)
+                bonus -= make_score(0, king_proximity(Us, blockSq + Up) * w);
 
             // If the pawn is free to advance, then increase the bonus
             if (pos.empty(blockSq))