]> git.sesse.net Git - stockfish/commit
Bug fix in do_null_move() and NNUE simplification.
authorsyzygy1 <3028851+syzygy1@users.noreply.github.com>
Sun, 6 Sep 2020 15:29:12 +0000 (17:29 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Tue, 8 Sep 2020 20:53:17 +0000 (22:53 +0200)
commitfc27d158c012341593518a05abf51903ecbcb495
treeb7e39ffd89861b5e3a845bc91a32b02a0e039f41
parentd539da19d2b13d70a81ab863f54046add0bc3b38
Bug fix in do_null_move() and NNUE simplification.

This fixes #3108 and removes some NNUE code that is currently not used.

At the moment, do_null_move() copies the accumulator from the previous
state into the new state, which is correct. It then clears the "computed_score"
flag because the side to move has changed, and with the other side to move
NNUE will return a completely different evaluation (normally with changed
sign but also with different NNUE-internal tempo bonus).

The problem is that do_null_move() clears the wrong flag. It clears the
computed_score flag of the old state, not of the new state. It turns out
that this almost never affects the search. For example, fixing it does not
change the current bench (but it does change the previous bench). This is
because the search code usually avoids calling evaluate() after a null move.

This PR corrects do_null_move() by removing the computed_score flag altogether.
The flag is not needed because nnue_evaluate() is never called twice on a position.

This PR also removes some unnecessary {}s and inserts a few blank lines
in the modified NNUE files in line with SF coding style.

Resulf ot STC non-regression test:
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 26328 W: 3118 L: 3012 D: 20198
Ptnml(0-2): 126, 2208, 8397, 2300, 133
https://tests.stockfishchess.org/tests/view/5f553ccc2d02727c56b36db1

closes https://github.com/official-stockfish/Stockfish/pull/3109

bench: 4109324
src/nnue/evaluate_nnue.cpp
src/nnue/nnue_accumulator.h
src/nnue/nnue_feature_transformer.h
src/position.cpp