Skip to content

Commit 0470bce

Browse files
committed
Detect fortresses a little bit quicker
In the so-called "hybrid" method of evaluation of current master, we use the classical eval (because of its speed) instead of the NNUE eval when the classical material balance approximation hints that the position is "winning enough" to rely on the classical eval. This trade-off idea between speed and accuracy works well in general, but in some fortress positions the classical eval is just bad. So in shuffling branches of the search tree, we (slowly) increase the thresehold so that eventually we don't trust classical anymore and switch to NNUE evaluation. This patch increases that threshold faster, so that we switch to NNUE quicker in shuffling branches. Idea is to incite Stockfish to spend less time in fortresses lines in the search tree, and spend more time searching the critical lines. passed STC: LLR: 2.96 (-2.94,2.94) <-0.50,2.50> Total: 47872 W: 3908 L: 3720 D: 40244 Ptnml(0-2): 122, 3053, 17419, 3199, 143 https://tests.stockfishchess.org/tests/view/60cef34b457376eb8bcab79d passed LTC: LLR: 2.93 (-2.94,2.94) <0.50,3.50> Total: 73616 W: 2326 L: 2143 D: 69147 Ptnml(0-2): 21, 1940, 32705, 2119, 23 https://tests.stockfishchess.org/tests/view/60cf6d842114332881e73528 Retested at LTC against lastest master: LLR: 2.93 (-2.94,2.94) <0.50,3.50> Total: 18264 W: 642 L: 532 D: 17090 Ptnml(0-2): 6, 479, 8055, 583, 9 https://tests.stockfishchess.org/tests/view/60d18cd540925195e7a6c351 closes official-stockfish#3578 Bench: 5139233
1 parent 9b82414 commit 0470bce

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/evaluate.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ namespace {
192192
// Threshold for lazy and space evaluation
193193
constexpr Value LazyThreshold1 = Value(1565);
194194
constexpr Value LazyThreshold2 = Value(1102);
195-
constexpr Value SpaceThreshold = Value(11551);
196-
constexpr Value NNUEThreshold1 = Value(800);
195+
constexpr Value SpaceThreshold = Value(11551);
197196

198197
// KingAttackWeights[PieceType] contains king attack weights by piece type
199198
constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 };
@@ -1103,14 +1102,14 @@ Value Eval::evaluate(const Position& pos) {
11031102
return nnue;
11041103
};
11051104

1106-
// If there is PSQ imbalance we use the classical eval.
1105+
// If there is PSQ imbalance we use the classical eval, but we switch to
1106+
// NNUE eval faster when shuffling or if the material on the board is high.
1107+
int r50 = pos.rule50_count();
11071108
Value psq = Value(abs(eg_value(pos.psq_score())));
1108-
int r50 = 16 + pos.rule50_count();
1109-
bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50;
1110-
1111-
v = largePsq ? Evaluation<NO_TRACE>(pos).value() // classical
1112-
: adjusted_NNUE(); // NNUE
1109+
bool classical = psq * 5 > (750 + pos.non_pawn_material() / 64) * (5 + r50);
11131110

1111+
v = classical ? Evaluation<NO_TRACE>(pos).value() // classical
1112+
: adjusted_NNUE(); // NNUE
11141113
}
11151114

11161115
// Damp down the evaluation linearly when shuffling

0 commit comments

Comments
 (0)