Tweak endgame scale factor
authorFabian Fichter <ianfab@users.noreply.github.com>
Tue, 30 Jun 2020 17:27:58 +0000 (19:27 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Tue, 30 Jun 2020 17:27:58 +0000 (19:27 +0200)
makruk STC
LLR: 2.99 (-2.94,2.94) [0.00,10.00]
Total: 2918 W: 272 L: 203 D: 2443
http://www.variantfishtest.org:6543/tests/view/5ef3c19a6e23db104fb88c5f

makruk LTC
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 8027 W: 495 L: 416 D: 7116
http://www.variantfishtest.org:6543/tests/view/5ef3c8db6e23db104fb88c68

src/material.cpp

index 46de4b1..e65c9cc 100644 (file)
@@ -222,12 +222,12 @@ Entry* probe(const Position& pos) {
   // advantage. This catches some trivial draws like KK, KBK and KNK and gives a
   // drawish scale factor for cases such as KRKBP and KmmKm (except for KBBKN).
   if (!pos.count<PAWN>(WHITE) && npm_w - npm_b <= BishopValueMg)
-      e->factor[WHITE] = uint8_t(npm_w <  RookValueMg   ? SCALE_FACTOR_DRAW :
-                                 npm_b <= BishopValueMg ? 4 : 14);
+      e->factor[WHITE] = uint8_t(npm_w <  RookValueMg && pos.count<ALL_PIECES>(WHITE) <= 2 ? SCALE_FACTOR_DRAW :
+                                 npm_b <= BishopValueMg && pos.count<ALL_PIECES>(WHITE) <= 3 ? 4 : 14);
 
   if (!pos.count<PAWN>(BLACK) && npm_b - npm_w <= BishopValueMg)
-      e->factor[BLACK] = uint8_t(npm_b <  RookValueMg   ? SCALE_FACTOR_DRAW :
-                                 npm_w <= BishopValueMg ? 4 : 14);
+      e->factor[BLACK] = uint8_t(npm_b <  RookValueMg && pos.count<ALL_PIECES>(BLACK) <= 2 ? SCALE_FACTOR_DRAW :
+                                 npm_w <= BishopValueMg && pos.count<ALL_PIECES>(BLACK) <= 3 ? 4 : 14);
   }
 
   // Evaluate the material imbalance. We use PIECE_TYPE_NONE as a place holder