From: Marco Costalba Date: Thu, 22 Aug 2013 11:02:20 +0000 (+0200) Subject: Retire redundant endgames X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=c4533e0d94a273cc10e0530a2953d369c6afbb8e Retire redundant endgames The case of two lone kings on the board is already considered by the "No pawns" scaling factor rules in material.cpp as is KBK and KNK. Moreover we had a small leak in endgames map because for KK endgame it happens white and black material keys are the same (both equal to zero), so when adding the black endgame in Endgames::add() we were overwriting the already exsisting white one, leading to a memory leak found by Valgrind. So remove the endgames althogheter and rely on scaling to correctly set the endgames value to a draw. No functional change. --- diff --git a/src/endgame.cpp b/src/endgame.cpp index cc98de90..96f85334 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -89,10 +89,7 @@ namespace { Endgames::Endgames() { - add("KK"); add("KPK"); - add("KBK"); - add("KNK"); add("KNNK"); add("KBNK"); add("KRKP"); @@ -411,9 +408,6 @@ Value Endgame::operator()(const Position& pos) const { /// 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; } diff --git a/src/endgame.h b/src/endgame.h index 5529eae1..49f39990 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -33,9 +33,6 @@ 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 diff --git a/src/material.cpp b/src/material.cpp index abad2abb..0f1e19b9 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -240,7 +240,8 @@ Entry* probe(const Position& pos, Table& entries, Endgames& endgames) { } } - // No pawns makes it difficult to win, even with a material advantage + // No pawns makes it difficult to win, even with a material advantage. This + // catches some trivial draws like KK, KBK and KNK if (!pos.count(WHITE) && npm_w - npm_b <= BishopValueMg) { e->factor[WHITE] = (uint8_t)