Evaluate endgame king proximity
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 4 Jun 2020 20:13:40 +0000 (22:13 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 4 Jun 2020 20:13:40 +0000 (22:13 +0200)
makruk STC
LLR: 2.98 (-2.94,2.94) [0.00,10.00]
Total: 1496 W: 171 L: 107 D: 1218
http://www.variantfishtest.org:6543/tests/view/5ed10e526e23db36d55f2c70

makruk LTC
LLR: 2.99 (-2.94,2.94) [0.00,10.00]
Total: 1810 W: 154 L: 92 D: 1564
http://www.variantfishtest.org:6543/tests/view/5ed36b986e23db36d55f2cc3

src/evaluate.cpp

index a11be4b..675ab8e 100644 (file)
@@ -136,6 +136,7 @@ namespace {
 
   // KingProximity contains a penalty according to distance from king
   constexpr Score KingProximity = S(1, 3);
+  constexpr Score EndgameKingProximity = S(0, 10);
 
   // Assorted bonuses and penalties
   constexpr Score BishopPawns        = S(  3,  7);
@@ -344,6 +345,9 @@ namespace {
         if ((pos.captures_to_hand() || pos.two_boards()) && pos.count<KING>(Them) && pos.count<KING>(Us))
             score -= KingProximity * distance(s, pos.square<KING>(Us)) * distance(s, pos.square<KING>(Them));
 
+        else if (pos.count<KING>(Us) && (Pt == FERS || Pt == SILVER))
+            score -= EndgameKingProximity * (distance(s, pos.square<KING>(Us)) - 2);
+
         if (Pt == BISHOP || Pt == KNIGHT)
         {
             // Bonus if piece is on an outpost square or can reach one