X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.cpp;h=a5390b1ab46227f59a0e1e3c5b10b148e542f0cb;hp=136ee0f6529002db6f33d3cf016b7f2cec55ba1c;hb=377d77dbe922b99ee34d686e4fe180698a9b535a;hpb=b48439e90643cb6f65f9e34d1421976883c12efc diff --git a/src/endgame.cpp b/src/endgame.cpp index 136ee0f6..a5390b1a 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -110,14 +110,6 @@ Endgames::Endgames() { } -template -void Endgames::add(const string& code) { - StateInfo st; - map()[Position().set(code, WHITE, &st).material_key()] = std::unique_ptr>(new Endgame(WHITE)); - map()[Position().set(code, BLACK, &st).material_key()] = std::unique_ptr>(new Endgame(BLACK)); -} - - /// Mate with KX vs K. This function is used to evaluate positions with /// king and plenty of material vs a lone king. It simply gives the /// attacking side a bonus for driving the defending king towards the edge @@ -606,7 +598,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { // If all pawns are ahead of the king, on a single rook file and // the king is within one file of the pawns, it's a draw. - if ( !(pawns & ~in_front_bb(weakSide, rank_of(ksq))) + if ( !(pawns & ~forward_ranks_bb(weakSide, ksq)) && !((pawns & ~FileABB) && (pawns & ~FileHBB)) && distance(ksq, lsb(pawns)) <= 1) return SCALE_FACTOR_DRAW; @@ -653,7 +645,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { if (relative_rank(strongSide, pawnSq) <= RANK_5) return SCALE_FACTOR_DRAW; - Bitboard path = forward_bb(strongSide, pawnSq); + Bitboard path = forward_file_bb(strongSide, pawnSq); if (path & pos.pieces(weakSide, KING)) return SCALE_FACTOR_DRAW; @@ -788,7 +780,7 @@ ScaleFactor Endgame::operator()(const Position& pos) const { // King needs to get close to promoting pawn to prevent knight from blocking. // Rules for this are very tricky, so just approximate. - if (forward_bb(strongSide, pawnSq) & pos.attacks_from(bishopSq)) + if (forward_file_bb(strongSide, pawnSq) & pos.attacks_from(bishopSq)) return ScaleFactor(distance(weakKingSq, pawnSq)); return SCALE_FACTOR_NONE;