From d9cac9a41492c3e54f3bb471606ec3a922a8ea0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ste=CC=81phane=20Nicolet?= Date: Sun, 1 Apr 2018 02:00:57 +0200 Subject: [PATCH 1/1] Simplify KBPKB endgame with opposite bishops When we reach a position with only two opposite colored bishops and one pawn on the board, current master would give it a scale factor of 9/64=0.14 in about one position out of 7200, and a scale factor of 0.0 in the 7199 others. The patch gives a scale factor of 0.0 in 100% of the cases. STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 55845 W: 11467 L: 11410 D: 32968 http://tests.stockfishchess.org/tests/view/5abc585f0ebc5902926cf15e LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 11915 W: 1852 L: 1719 D: 8344 http://tests.stockfishchess.org/tests/view/5abc7f750ebc5902926cf18c We also have exhaustive coverage analysis of this patch effect by Alain Savard, comparing the perfect evaluation given by the Syzygy tablebase with the heuristic play after this patch for the set of all legal positions of the KBPKP endgame with opposite bishops, in the comments thread for this pull request: https://github.com/official-stockfish/Stockfish/pull/1520 Alain's conclusion: > According to this definition and the data, I consider this PR is > identical to master to "solve for draw" and slightly better than > master to solve earlier for "wins". Note: this patch is a side effect of an ongoing effort to improve the evaluation of positions involving a pair of opposite bishops. See the GitHub diff of this LTC test which almost passed at sprt[0..5] for a discussion: http://tests.stockfishchess.org/tests/view/5ab9030b0ebc5902932cbf93 No functional change (at small bench depths) --- src/endgame.cpp | 23 +---------------------- src/evaluate.cpp | 5 ++--- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/endgame.cpp b/src/endgame.cpp index 55e4483d..db67ce95 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -631,29 +631,8 @@ ScaleFactor Endgame::operator()(const Position& pos) const { // Case 2: Opposite colored bishops if (opposite_colors(strongBishopSq, weakBishopSq)) - { - // We assume that the position is drawn in the following three situations: - // - // a. The pawn is on rank 5 or further back. - // b. The defending king is somewhere in the pawn's path. - // c. The defending bishop attacks some square along the pawn's path, - // and is at least three squares away from the pawn. - // - // These rules are probably not perfect, but in practice they work - // reasonably well. - - if (relative_rank(strongSide, pawnSq) <= RANK_5) - return SCALE_FACTOR_DRAW; - - Bitboard path = forward_file_bb(strongSide, pawnSq); - - if (path & pos.pieces(weakSide, KING)) - return SCALE_FACTOR_DRAW; + return SCALE_FACTOR_DRAW; - if ( (pos.attacks_from(weakBishopSq) & path) - && distance(weakBishopSq, pawnSq) >= 3) - return SCALE_FACTOR_DRAW; - } return SCALE_FACTOR_NONE; } diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 69c32785..f4811aea 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -800,11 +800,10 @@ namespace { { if (pos.opposite_bishops()) { - // Endgame with opposite-colored bishops and no other pieces (ignoring pawns) - // is almost a draw, in case of KBP vs KB, it is even more a draw. + // Endgame with opposite-colored bishops and no other pieces is almost a draw if ( pos.non_pawn_material(WHITE) == BishopValueMg && pos.non_pawn_material(BLACK) == BishopValueMg) - sf = more_than_one(pos.pieces(PAWN)) ? 31 : 9; + sf = 31; // Endgame with opposite-colored bishops, but also other pieces. Still // a bit drawish, but not as drawish as with only the two bishops. -- 2.39.2