- // Use classical evaluation for really low piece endgames.
- // 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<PAWN>() < 2);
-
- v = largePsq || lowPieceEndgame ? Evaluation<NO_TRACE>(pos).value() // classical
- : adjusted_NNUE(); // 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
- && !lowPieceEndgame
- && ( abs(v) * 16 < NNUEThreshold2 * r50
- || ( pos.opposite_bishops()
- && abs(v) * 16 < (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50)))
- v = adjusted_NNUE();