X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fendgame.cpp;h=96f8533453ebf41fb0366e9e5c82e2365c34c923;hb=5e331f9618a0a6dcab888cf17898feaa914ff37c;hp=4323a4209442d10601b9711018422435d3344fac;hpb=a4c11b71acc4aeab032128d4ba9d0d4ccd51aa20;p=stockfish diff --git a/src/endgame.cpp b/src/endgame.cpp index 4323a420..96f85334 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -131,13 +131,11 @@ Value Endgame::operator()(const Position& pos) const { assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(!pos.count(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(pos).size()) { - return VALUE_DRAW; - } + if (pos.side_to_move() == weakerSide && !MoveList(pos).size()) + return VALUE_DRAW; Square winnerKSq = pos.king_square(strongerSide); Square loserKSq = pos.king_square(weakerSide); @@ -149,9 +147,8 @@ Value Endgame::operator()(const Position& pos) const { if ( pos.count(strongerSide) || pos.count(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 +407,10 @@ Value Endgame::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::operator()(const Position&) const { - return VALUE_DRAW; -} +/// 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; -} /// 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