- // If result of a classical evaluation is much lower than threshold fall back to NNUE
- if (useNNUE && !useClassical)
- {
- Value nnue = NNUE::evaluate(pos, true); // NNUE
- int scale = 1136 + 20 * pos.non_pawn_material() / 1024;
- Color stm = pos.side_to_move();
- Value optimism = pos.this_thread()->optimism[stm];
- Value psq = (stm == WHITE ? 1 : -1) * eg_value(pos.psq_score());
- int complexity = 35 * abs(nnue - psq) / 256;
-
- optimism = optimism * (44 + complexity) / 32;
- v = (nnue + optimism) * scale / 1024 - optimism;
-
- if (pos.is_chess960())
- v += fix_FRC(pos);
+ optimism = optimism * (272 + nnueComplexity) / 256;
+ v = (nnue * scale + optimism * (scale - 748)) / 1024;