]> git.sesse.net Git - stockfish/blobdiff - src/endgame.cpp
Restore development version
[stockfish] / src / endgame.cpp
index 4323a4209442d10601b9711018422435d3344fac..cc98de90d4f40f71f900c04c1bbc71bd2322ec11 100644 (file)
@@ -89,7 +89,10 @@ namespace {
 
 Endgames::Endgames() {
 
+  add<KK>("KK");
   add<KPK>("KPK");
+  add<KBK>("KBK");
+  add<KNK>("KNK");
   add<KNNK>("KNNK");
   add<KBNK>("KBNK");
   add<KRKP>("KRKP");
@@ -131,13 +134,11 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
 
   assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
   assert(!pos.count<PAWN>(weakerSide));
+  assert(!pos.checkers()); // Eval is never called when in check
 
   // Stalemate detection with lone king
-  if (    pos.side_to_move() == weakerSide
-      && !pos.checkers()
-      && !MoveList<LEGAL>(pos).size()) {
-    return VALUE_DRAW;
-  }
+  if (pos.side_to_move() == weakerSide && !MoveList<LEGAL>(pos).size())
+      return VALUE_DRAW;
 
   Square winnerKSq = pos.king_square(strongerSide);
   Square loserKSq = pos.king_square(weakerSide);
@@ -149,9 +150,8 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
 
   if (   pos.count<QUEEN>(strongerSide)
       || pos.count<ROOK>(strongerSide)
-      || pos.bishop_pair(strongerSide)) {
-    result += VALUE_KNOWN_WIN;
-  }
+      || pos.bishop_pair(strongerSide))
+      result += VALUE_KNOWN_WIN;
 
   return strongerSide == pos.side_to_move() ? result : -result;
 }
@@ -410,17 +410,13 @@ Value Endgame<KBBKN>::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<KmmKm>::operator()(const Position&) const {
-  return VALUE_DRAW;
-}
+/// 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;
-}
 
 /// 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