S(0, 0), S(3, 44), S(37, 68), S(42, 60), S(0, 39), S(58, 43)
};
+ constexpr Value CorneredBishop = Value(50);
+
// Assorted bonuses and penalties
constexpr Score UncontestedOutpost = S( 1, 10);
constexpr Score BishopOnKingRing = S( 24, 0);
constexpr Score BishopXRayPawns = S( 4, 5);
- constexpr Value CorneredBishopV = Value(50);
- constexpr Score CorneredBishop = S(CorneredBishopV, CorneredBishopV);
constexpr Score FlankAttacks = S( 8, 0);
constexpr Score Hanging = S( 69, 36);
constexpr Score KnightOnQueen = S( 16, 11);
{
Direction d = pawn_push(Us) + (file_of(s) == FILE_A ? EAST : WEST);
if (pos.piece_on(s + d) == make_piece(Us, PAWN))
- score -= !pos.empty(s + d + pawn_push(Us)) ? CorneredBishop * 4
- : CorneredBishop * 3;
+ score -= !pos.empty(s + d + pawn_push(Us)) ? 4 * make_score(CorneredBishop, CorneredBishop)
+ : 3 * make_score(CorneredBishop, CorneredBishop);
}
}
}
if ( pos.piece_on(SQ_A1) == W_BISHOP
&& pos.piece_on(SQ_B2) == W_PAWN)
- correction += !pos.empty(SQ_B3) ? -CorneredBishopV * 4
- : -CorneredBishopV * 3;
+ correction += !pos.empty(SQ_B3) ? -CorneredBishop * 4
+ : -CorneredBishop * 3;
if ( pos.piece_on(SQ_H1) == W_BISHOP
&& pos.piece_on(SQ_G2) == W_PAWN)
- correction += !pos.empty(SQ_G3) ? -CorneredBishopV * 4
- : -CorneredBishopV * 3;
+ correction += !pos.empty(SQ_G3) ? -CorneredBishop * 4
+ : -CorneredBishop * 3;
if ( pos.piece_on(SQ_A8) == B_BISHOP
&& pos.piece_on(SQ_B7) == B_PAWN)
- correction += !pos.empty(SQ_B6) ? CorneredBishopV * 4
- : CorneredBishopV * 3;
+ correction += !pos.empty(SQ_B6) ? CorneredBishop * 4
+ : CorneredBishop * 3;
if ( pos.piece_on(SQ_H8) == B_BISHOP
&& pos.piece_on(SQ_G7) == B_PAWN)
- correction += !pos.empty(SQ_G6) ? CorneredBishopV * 4
- : CorneredBishopV * 3;
+ correction += !pos.empty(SQ_G6) ? CorneredBishop * 4
+ : CorneredBishop * 3;
return pos.side_to_move() == WHITE ? Value(correction)
: -Value(correction);
// Scale and shift NNUE for compatibility with search and classical evaluation
auto adjusted_NNUE = [&]()
{
- int material = pos.non_pawn_material() + 2 * PawnValueMg * pos.count<PAWN>();
- int scale = 641
+ int material = pos.non_pawn_material() + 4 * PawnValueMg * pos.count<PAWN>();
+ int scale = 580
+ material / 32
- 4 * pos.rule50_count();
// 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
+ if ( largePsq
+ && !strongClassical
&& ( abs(v) * 16 < NNUEThreshold2 * r50
|| ( pos.opposite_bishops()
&& abs(v) * 16 < (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50