From ce1bdc71959be359a0d07088fe499a7da7e1ec8e Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Fri, 5 Jun 2020 11:51:12 +0200 Subject: [PATCH] Add KRKS endgame evaluation makruk STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 5606 W: 531 L: 449 D: 4626 http://www.variantfishtest.org:6543/tests/view/5ed3d34a6e23db36d55f2ce0 --- src/endgame.cpp | 20 ++++++++++++++++++++ src/endgame.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/endgame.cpp b/src/endgame.cpp index 5bc23c2..b470161 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -124,6 +124,7 @@ namespace Endgames { add("KNSFKR"); add("KSFK"); add("KSFKF"); + add("KRKS"); add("KNPK"); add("KNPKB"); @@ -519,6 +520,25 @@ Value Endgame::operator()(const Position& pos) const { } +/// KR vs KS +template<> +Value Endgame::operator()(const Position& pos) const { + + assert(verify_material(pos, strongSide, RookValueMg, 0)); + assert(verify_material(pos, weakSide, SilverValueMg, 0)); + + Square winnerKSq = pos.square(strongSide); + Square loserKSq = pos.square(weakSide); + + Value result = RookValueEg + - SilverValueEg + + PushToEdges[map_to_standard_board(pos, loserKSq)] + + PushClose[distance(winnerKSq, loserKSq)]; + + 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 diff --git a/src/endgame.h b/src/endgame.h index a0849a7..b674e3e 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -54,6 +54,7 @@ enum EndgameCode { KNSFKR, // KNSFKR vs K KSFK, // KSF vs K KSFKF, // KSF vs KF + KRKS, // KR vs KS SCALING_FUNCTIONS, KBPsK, // KB and pawns vs K -- 1.7.0.4