X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=ec54d4e69ea5114265e0d47d05a4fd0cc68f2c4b;hp=d7cb2b3c8c58541a54d0e662aff2d25110a1e07f;hb=9b2635634714558cc492d1c31db7c93127369c88;hpb=0347339970b68b998c7202e22c01560850dcd13e diff --git a/src/endgame.cpp b/src/endgame.cpp index d7cb2b3c..ec54d4e6 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -22,6 +22,7 @@ #include "bitcount.h" #include "endgame.h" +#include "movegen.h" using std::string; @@ -82,21 +83,6 @@ namespace { template void delete_endgame(const typename M::value_type& p) { delete p.second; } - // Fast stalemate detection with lone king - bool is_kxk_stalemate(const Position &pos, const Color c) { - if ( pos.side_to_move() == c && - !pos.in_check()) { - const Square from = pos.king_square(c); - Bitboard b = pos.attacks_from(from); - while (b) { - // Assume there are no pinned pieces, as it is a lone king - if (pos.pl_move_is_legal(make_move(from, pop_1st_bit(&b)), 0)) - return false; - } - return true; - } - return false; - } } // namespace @@ -147,7 +133,10 @@ Value Endgame::operator()(const Position& pos) const { assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO); - if (is_kxk_stalemate(pos, weakerSide)) { + // Stalemate detection with lone king + if ( pos.side_to_move() == weakerSide + && !pos.in_check() + && !MoveList(pos).size()) { return VALUE_DRAW; }