Enhance king protector term for drop variants
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 29 Nov 2018 13:35:42 +0000 (14:35 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 29 Nov 2018 13:35:42 +0000 (14:35 +0100)
shogi
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 1354 W: 713 L: 594 D: 47

euroshogi
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 574 W: 307 L: 245 D: 22

minishogi
LLR: 2.95 (-2.94,2.94) [-10.00,5.00]
Total: 2006 W: 950 L: 901 D: 155

crazyhouse STC
LLR: 2.96 (-2.94,2.94) [-10.00,5.00]
Total: 855 W: 449 L: 388 D: 18
http://35.161.250.236:6543/tests/view/5bf981d86e23db7639060cab

crazyhouse LTC
LLR: 2.98 (-2.94,2.94) [-10.00,5.00]
Total: 2573 W: 1284 L: 1235 D: 54
http://35.161.250.236:6543/tests/view/5bfa5e486e23db7639060cae

src/evaluate.cpp

index e79b8f1..12896ea 100644 (file)
@@ -162,7 +162,7 @@ namespace {
   constexpr int PassedDanger[RANK_NB] = { 0, 0, 0, 3, 6, 12, 21 };
 
   // KingProtector[PieceType-2] contains a penalty according to distance from king
-  constexpr Score KingProtector[PIECE_TYPE_NB - 2] = { S(3, 5), S(4, 3), S(3, 0), S(1, -1) };
+  constexpr Score KingProtector[PIECE_TYPE_NB - 2] = { S(3, 5), S(4, 3), S(3, 0), S(1, -1), S(2, 2) };
 
   // Assorted bonuses and penalties
   constexpr Score BishopPawns        = S(  3,  5);
@@ -351,7 +351,12 @@ namespace {
 
         // Penalty if the piece is far from the king
         if (pos.count<KING>(Us))
-            score -= KingProtector[Pt - 2] * distance(s, pos.square<KING>(Us));
+        {
+            int dist = distance(s, pos.square<KING>(Us));
+            if (pos.captures_to_hand() && pos.count<KING>(Them))
+                dist *= distance(s, pos.square<KING>(Them));
+            score -= KingProtector[std::min(Pt - 2, QUEEN - 1)] * dist;
+        }
 
         if (Pt == BISHOP || Pt == KNIGHT)
         {