]> git.sesse.net Git - stockfish/commitdiff
Retire redundant endgames
authorMarco Costalba <mcostalba@gmail.com>
Thu, 22 Aug 2013 11:02:20 +0000 (13:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 22 Aug 2013 11:13:06 +0000 (13:13 +0200)
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.

src/endgame.cpp
src/endgame.h
src/material.cpp

index cc98de90d4f40f71f900c04c1bbc71bd2322ec11..96f8533453ebf41fb0366e9e5c82e2365c34c923 100644 (file)
@@ -89,10 +89,7 @@ namespace {
 
 Endgames::Endgames() {
 
 
 Endgames::Endgames() {
 
-  add<KK>("KK");
   add<KPK>("KPK");
   add<KPK>("KPK");
-  add<KBK>("KBK");
-  add<KNK>("KNK");
   add<KNNK>("KNNK");
   add<KBNK>("KBNK");
   add<KRKP>("KRKP");
   add<KNNK>("KNNK");
   add<KBNK>("KBNK");
   add<KRKP>("KRKP");
@@ -411,9 +408,6 @@ Value Endgame<KBBKN>::operator()(const Position& pos) const {
 
 
 /// Some cases of trivial draws
 
 
 /// Some cases of trivial draws
-template<> Value Endgame<KK>::operator()(const Position&) const { return VALUE_DRAW; }
-template<> Value Endgame<KBK>::operator()(const Position&) const { return VALUE_DRAW; }
-template<> Value Endgame<KNK>::operator()(const Position&) const { return VALUE_DRAW; }
 template<> Value Endgame<KNNK>::operator()(const Position&) const { return VALUE_DRAW; }
 template<> Value Endgame<KmmKm>::operator()(const Position&) const { return VALUE_DRAW; }
 
 template<> Value Endgame<KNNK>::operator()(const Position&) const { return VALUE_DRAW; }
 template<> Value Endgame<KmmKm>::operator()(const Position&) const { return VALUE_DRAW; }
 
index 5529eae108429e35fba55f9a1c7ec362c68c3789..49f39990ba513e6ca8584df55fa9ebadddfe6d9d 100644 (file)
@@ -33,9 +33,6 @@ enum EndgameType {
 
   // Evaluation functions
 
 
   // 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
   KNNK,  // KNN vs K
   KXK,   // Generic "mate lone king" eval
   KBNK,  // KBN vs K
index abad2abb923e053291bb22e41d21585b8573e47d..0f1e19b9ee4a954f69bb84844e9227110f21709a 100644 (file)
@@ -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<PAWN>(WHITE) && npm_w - npm_b <= BishopValueMg)
   {
       e->factor[WHITE] = (uint8_t)
   if (!pos.count<PAWN>(WHITE) && npm_w - npm_b <= BishopValueMg)
   {
       e->factor[WHITE] = (uint8_t)