Skip to content

Commit cefd5b3

Browse files
committed
Sometimes change the (materialist, positional) balance
Our new nets output two values for the side to move in the last layer. We can interpret the first value as a material evaluation of the position, and the second one as the dynamic, positional value of the location of pieces. This patch changes the balance for the (materialist, positional) parts of the score from (128, 128) to (121, 135) when the piece material is equal between the two players, and keeps the standard (128, 128) balance when one player has at least a quality advantage. Passed STC: LLR: 2.93 (-2.94,2.94) <-0.50,2.50> Total: 15936 W: 1421 L: 1266 D: 13249 Ptnml(0-2): 37, 1037, 5694, 1134, 66 https://tests.stockfishchess.org/tests/view/60a82df9ce8ea25a3ef0408f Passed LTC: LLR: 2.94 (-2.94,2.94) <0.50,3.50> Total: 13904 W: 516 L: 410 D: 12978 Ptnml(0-2): 4, 374, 6088, 484, 2 https://tests.stockfishchess.org/tests/view/60a8bbf9ce8ea25a3ef04101 closes official-stockfish/Stockfish#3492 Bench: 3856635
1 parent ff4c222 commit cefd5b3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/nnue/evaluate_nnue.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,26 @@ namespace Stockfish::Eval::NNUE {
158158
ASSERT_ALIGNED(buffer, alignment);
159159

160160
const std::size_t bucket = (pos.count<ALL_PIECES>() - 1) / 4;
161-
162161
const auto [psqt, lazy] = featureTransformer->transform(pos, transformedFeatures, bucket);
163-
if (lazy) {
162+
163+
if (lazy)
164164
return static_cast<Value>(psqt / OutputScale);
165-
} else {
165+
else
166+
{
166167
const auto output = network[bucket]->propagate(transformedFeatures, buffer);
167-
return static_cast<Value>((output[0] + psqt) / OutputScale);
168+
169+
int materialist = psqt;
170+
int positional = output[0];
171+
172+
int delta_npm = abs(pos.non_pawn_material(WHITE) - pos.non_pawn_material(BLACK));
173+
int entertainment = (delta_npm <= BishopValueMg - KnightValueMg ? 7 : 0);
174+
175+
int A = 128 - entertainment;
176+
int B = 128 + entertainment;
177+
178+
int sum = (A * materialist + B * positional) / 128;
179+
180+
return static_cast<Value>( sum / OutputScale );
168181
}
169182
}
170183

0 commit comments

Comments
 (0)