From: dsmsgms Date: Mon, 12 Apr 2021 15:06:22 +0000 (-0300) Subject: Use classical eval for Bishop vs Pawns X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=a7ab92ec25c91e8413630c52cfc2db6b4ecacf0c Use classical eval for Bishop vs Pawns NNUE evaluation is incapable of recognizing trivially drawn bishop endgames (the wrong-colored rook pawn), which are in fact ubiquitous and stock standard in chess analysis. Switching off NNUE evaluation in KBPs vs KPs endgames is a measure that stops Stockfish from trading down to a drawn version of these endings when we presumably have advantage. The patch is able to edge over master in endgame positions. Patch tested for Elo gain with the "endgame.epd" book, and verified for non-regression with our usual book (see the pull request for details). STC: LLR: 2.93 (-2.94,2.94) {-0.20,1.10} Total: 33232 W: 6655 L: 6497 D: 20080 Ptnml(0-2): 4, 2342, 11769, 2494, 7 https://tests.stockfishchess.org/tests/view/6074a52981417533789605b8 LTC: LLR: 2.93 (-2.94,2.94) {0.20,0.90} Total: 159056 W: 29799 L: 29378 D: 99879 Ptnml(0-2): 7, 9004, 61085, 9425, 7 https://tests.stockfishchess.org/tests/view/6074c39a81417533789605ca Closes https://github.com/official-stockfish/Stockfish/pull/3427 Bench: 4503918 blah --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 789e2859..ba3de70b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1104,23 +1104,26 @@ Value Eval::evaluate(const Position& pos) { return nnue; }; - // If there is PSQ imbalance use classical eval, with small probability if it is small + // If there is PSQ imbalance we use the classical eval. We also introduce + // a small probability of using the classical eval when PSQ imbalance is small. Value psq = Value(abs(eg_value(pos.psq_score()))); int r50 = 16 + pos.rule50_count(); bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50; bool classical = largePsq || (psq > PawnValueMg / 4 && !(pos.this_thread()->nodes & 0xB)); // Use classical evaluation for really low piece endgames. - // The most critical case is a bishop + A/H file pawn vs naked king draw. - bool strongClassical = pos.non_pawn_material() < 2 * RookValueMg && pos.count() < 2; + // One critical case is the draw for bishop + A/H file pawn vs naked king. + bool lowPieceEndgame = pos.non_pawn_material() == BishopValueMg + || (pos.non_pawn_material() < 2 * RookValueMg && pos.count() < 2); - v = classical || strongClassical ? Evaluation(pos).value() : adjusted_NNUE(); + v = classical || lowPieceEndgame ? Evaluation(pos).value() + : adjusted_NNUE(); // If the classical eval is small and imbalance large, use NNUE nevertheless. - // For the case of opposite colored bishops, switch to NNUE eval with - // small probability if the classical eval is less than the threshold. - if ( largePsq - && !strongClassical + // For the case of opposite colored bishops, switch to NNUE eval with small + // probability if the classical eval is less than the threshold. + if ( largePsq + && !lowPieceEndgame && ( abs(v) * 16 < NNUEThreshold2 * r50 || ( pos.opposite_bishops() && abs(v) * 16 < (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50