Add KSFKF endgame evaluation
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 31 May 2020 09:14:08 +0000 (11:14 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 31 May 2020 09:14:07 +0000 (11:14 +0200)
makruk STC
LLR: 2.98 (-2.94,2.94) [0.00,10.00]
Total: 1438 W: 169 L: 105 D: 1164
http://www.variantfishtest.org:6543/tests/view/5ed16b406e23db36d55f2c78

src/endgame.cpp
src/endgame.h

index c6c0186..14ef2d4 100644 (file)
@@ -123,6 +123,7 @@ namespace Endgames {
     add<KNFK>("KNFK");
     add<KNSFKR>("KNSFKR");
     add<KSFK>("KSFK");
+    add<KSFKF>("KSFKF");
 
     add<KNPK>("KNPK");
     add<KNPKB>("KNPKB");
@@ -455,7 +456,7 @@ Value Endgame<KNFK>::operator()(const Position& pos) const {
   }
 
   Value result =  Value(PushClose[distance(winnerKSq, loserKSq)])
-                + PushToCorners[map_to_standard_board(pos, loserKSq)] / 10;
+                + (PushToCorners[map_to_standard_board(pos, loserKSq)] - 3000) / 10;
 
   return strongSide == pos.side_to_move() ? result : -result;
 }
@@ -497,6 +498,26 @@ Value Endgame<KSFK>::operator()(const Position& pos) const {
 }
 
 
+/// Mate with KSF vs KF.
+template<>
+Value Endgame<KSFKF>::operator()(const Position& pos) const {
+
+  assert(verify_material(pos, strongSide, SilverValueMg + FersValueMg, 0));
+  assert(verify_material(pos, weakSide, FersValueMg, 0));
+
+  Square winnerKSq = pos.square<KING>(strongSide);
+  Square loserKSq = pos.square<KING>(weakSide);
+  Square fersSq = pos.square<FERS>(weakSide);
+
+  Value result =  SilverValueEg
+                + PushClose[distance(winnerKSq, loserKSq)]
+                + PushAway[distance(fersSq, loserKSq)]
+                + PushToOpposingSideEdges[map_to_standard_board(pos, relative_square(strongSide, loserKSq, pos.max_rank()))];
+
+  return strongSide == pos.side_to_move() ? result : -result;
+}
+
+
 /// KB and one or more pawns vs K. It checks for draws with rook pawns and
 /// a bishop of the wrong color. If such a draw is detected, SCALE_FACTOR_DRAW
 /// is returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling
index 3ce2b0e..ed53761 100644 (file)
@@ -53,6 +53,7 @@ enum EndgameCode {
   KNFK,  // KNF vs K
   KNSFKR,  // KNSFKR vs K
   KSFK,  // KSF vs K
+  KSFKF,  // KSF vs KF
 
   SCALING_FUNCTIONS,
   KBPsK,   // KB and pawns vs K