Generalize passed pawn evaluation
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 1 Mar 2019 18:39:49 +0000 (19:39 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 1 Mar 2019 18:55:42 +0000 (19:55 +0100)
losalamos
LLR: 2.99 (-2.94,2.94) [-10.00,5.00]
Total: 140 W: 56 L: 13 D: 71

ai-wok
LLR: 3.04 (-2.94,2.94) [-10.00,5.00]
Total: 194 W: 112 L: 53 D: 29

src/evaluate.cpp

index 95ea180..2b0d228 100644 (file)
@@ -741,7 +741,7 @@ namespace {
 
         assert(!(pos.pieces(Them, PAWN) & forward_file_bb(Us, s + Up)));
 
-        int r = relative_rank(Us, s, pos.max_rank());
+        int r = std::max(RANK_8 - std::max(pos.promotion_rank() - relative_rank(Us, s, pos.max_rank()), 0), 0);
         int w = PassedDanger[r];
 
         Score bonus = PassedRank[r];
@@ -758,7 +758,7 @@ namespace {
                                         - king_proximity(Us,   blockSq) * 2) * w);
 
                 // If blockSq is not the queening square then consider also a second push
-                if (r != RANK_7)
+                if (r != pos.promotion_rank() - 1)
                     bonus -= make_score(0, king_proximity(Us, blockSq + Up) * w);
             }