]> git.sesse.net Git - stockfish/blobdiff - src/endgame.cpp
Streamline time computation
[stockfish] / src / endgame.cpp
index cff5e6994054699fb40aec7c33404a7fb40a7073..e896e778e96aa8347b3f00405c26eddf580f97f5 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");
@@ -410,17 +413,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
@@ -704,7 +703,7 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
       // Does the defending king block the pawns?
       if (   square_distance(ksq, relative_square(strongerSide, SQ_A8)) <= 1
           || (    file_of(ksq) == FILE_A
-              && !(in_front_bb(strongerSide, ksq) & pawns)))
+              && !(in_front_bb(strongerSide, rank_of(ksq)) & pawns)))
           return SCALE_FACTOR_DRAW;
   }
   // Are all pawns on the 'h' file?
@@ -713,7 +712,7 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
     // Does the defending king block the pawns?
     if (   square_distance(ksq, relative_square(strongerSide, SQ_H8)) <= 1
         || (    file_of(ksq) == FILE_H
-            && !(in_front_bb(strongerSide, ksq) & pawns)))
+            && !(in_front_bb(strongerSide, rank_of(ksq)) & pawns)))
         return SCALE_FACTOR_DRAW;
   }
   return SCALE_FACTOR_NONE;