From 6373e88b5b13d23646ff50944b49b74a96bb5915 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 27 Jul 2013 08:22:12 +0200 Subject: [PATCH] Fix an assert in KBK endgame The endgame king + minor vs king is erroneusly detected as king + minor vs king + minor Here the fix is to detect king + minor earlier, in particular to add these trivial cases to endgame evaluation functions. Spotted by Reuven Peleg bench: 4727133 --- src/endgame.cpp | 19 +++++++++---------- src/endgame.h | 5 ++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/endgame.cpp b/src/endgame.cpp index 4323a420..e896e778 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -89,7 +89,10 @@ namespace { Endgames::Endgames() { + add("KK"); add("KPK"); + add("KBK"); + add("KNK"); add("KNNK"); add("KBNK"); add("KRKP"); @@ -410,17 +413,13 @@ Value Endgame::operator()(const Position& pos) const { } -/// K and two minors vs K and one or two minors or K and two knights against -/// king alone are always draw. -template<> -Value Endgame::operator()(const Position&) const { - return VALUE_DRAW; -} +/// Some cases of trivial draws +template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } +template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } +template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } +template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } +template<> Value Endgame::operator()(const Position&) const { return VALUE_DRAW; } -template<> -Value Endgame::operator()(const Position&) const { - return VALUE_DRAW; -} /// K, bishop 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 diff --git a/src/endgame.h b/src/endgame.h index 7f3ce6fb..5529eae1 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -33,6 +33,10 @@ enum EndgameType { // Evaluation functions + KK, // K vs K + KBK, // KB vs K + KNK, // KN vs K + KNNK, // KNN vs K KXK, // Generic "mate lone king" eval KBNK, // KBN vs K KPK, // KP vs K @@ -42,7 +46,6 @@ enum EndgameType { KQKP, // KQ vs KP KQKR, // KQ vs KR KBBKN, // KBB vs KN - KNNK, // KNN vs K KmmKm, // K and two minors vs K and one or two minors -- 2.39.2