X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=ec54d4e69ea5114265e0d47d05a4fd0cc68f2c4b;hp=00c707267575d816c5c0d12750768b9fa9610038;hb=9b2635634714558cc492d1c31db7c93127369c88;hpb=d98150dffc69a810b0b842244aec0d29deddabfb diff --git a/src/endgame.cpp b/src/endgame.cpp index 00c70726..ec54d4e6 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -22,7 +22,7 @@ #include "bitcount.h" #include "endgame.h" -#include "pawns.h" +#include "movegen.h" using std::string; @@ -133,6 +133,13 @@ Value Endgame::operator()(const Position& pos) const { assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO); assert(pos.piece_count(weakerSide, PAWN) == VALUE_ZERO); + // Stalemate detection with lone king + if ( pos.side_to_move() == weakerSide + && !pos.in_check() + && !MoveList(pos).size()) { + return VALUE_DRAW; + } + Square winnerKSq = pos.king_square(strongerSide); Square loserKSq = pos.king_square(weakerSide); @@ -143,9 +150,9 @@ Value Endgame::operator()(const Position& pos) const { if ( pos.piece_count(strongerSide, QUEEN) || pos.piece_count(strongerSide, ROOK) - || pos.piece_count(strongerSide, BISHOP) > 1) - // TODO: check for two equal-colored bishops! - result += VALUE_KNOWN_WIN; + || pos.both_color_bishops(strongerSide)) { + result += VALUE_KNOWN_WIN; + } return strongerSide == pos.side_to_move() ? result : -result; } @@ -416,7 +423,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { && abs(file_of(kingSq) - pawnFile) <= 1) { // The bishop has the wrong color, and the defending king is on the - // file of the pawn(s) or the neighboring file. Find the rank of the + // file of the pawn(s) or the adjacent file. Find the rank of the // frontmost pawn. Rank rank; if (strongerSide == WHITE) @@ -768,7 +775,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { return SCALE_FACTOR_NONE; case 1: - // Pawns on neighboring files. Draw if defender firmly controls the square + // Pawns on adjacent files. Draw if defender firmly controls the square // in front of the frontmost pawn's path, and the square diagonally behind // this square on the file of the other pawn. if ( ksq == blockSq1