- 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.
- if ( pos.non_pawn_material(WHITE) == BishopValueMg
- && pos.non_pawn_material(BLACK) == BishopValueMg)
- sf = more_than_one(pos.pieces(PAWN)) ? 31 : 9;
-
- // Endgame with opposite-colored bishops, but also other pieces. Still
- // a bit drawish, but not as drawish as with only the two bishops.
- else
- sf = 46;
- }
- // Endings where weaker side can place his king in front of the enemy's
- // pawns are drawish.
- else if ( abs(eg) <= BishopValueEg
- && pos.count<PAWN>(strongSide) <= 2
- && !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide)))
- sf = 37 + 7 * pos.count<PAWN>(strongSide);
+ if ( pos.opposite_bishops()
+ && pos.non_pawn_material(WHITE) == BishopValueMg
+ && pos.non_pawn_material(BLACK) == BishopValueMg)
+ sf = 8 + 4 * pe->pawn_asymmetry();
+ else
+ sf = std::min(40 + (pos.opposite_bishops() ? 2 : 7) * pos.count<PAWN>(strongSide), sf);
+