Reduce from 3 to 2. Make the intent of the states clearer.
STC: https://tests.stockfishchess.org/tests/view/
60c50111457376eb8bcaad03
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 61888 W: 5007 L: 4944 D: 51937
Ptnml(0-2): 164, 3947, 22649, 4030, 154
LTC: https://tests.stockfishchess.org/tests/view/
60c52b1c457376eb8bcaad2c
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 20248 W: 688 L: 618 D: 18942
Ptnml(0-2): 7, 551, 8946, 605, 15
closes https://github.com/official-stockfish/Stockfish/pull/3548
No functional change.
namespace Stockfish::Eval::NNUE {
namespace Stockfish::Eval::NNUE {
- // The accumulator of a StateInfo without parent is set to the INIT state
- enum AccumulatorState { EMPTY, COMPUTED, INIT };
-
// Class that holds the result of affine transformation of input features
struct alignas(CacheLineSize) Accumulator {
std::int16_t accumulation[2][TransformedFeatureDimensions];
std::int32_t psqtAccumulation[2][PSQTBuckets];
// Class that holds the result of affine transformation of input features
struct alignas(CacheLineSize) Accumulator {
std::int16_t accumulation[2][TransformedFeatureDimensions];
std::int32_t psqtAccumulation[2][PSQTBuckets];
- AccumulatorState state[2];
};
} // namespace Stockfish::Eval::NNUE
};
} // namespace Stockfish::Eval::NNUE
// of the estimated gain in terms of features to be added/subtracted.
StateInfo *st = pos.state(), *next = nullptr;
int gain = FeatureSet::refresh_cost(pos);
// of the estimated gain in terms of features to be added/subtracted.
StateInfo *st = pos.state(), *next = nullptr;
int gain = FeatureSet::refresh_cost(pos);
- while (st->accumulator.state[perspective] == EMPTY)
+ while (st->previous && !st->accumulator.computed[perspective])
{
// This governs when a full feature refresh is needed and how many
// updates are better than just one full refresh.
{
// This governs when a full feature refresh is needed and how many
// updates are better than just one full refresh.
- if (st->accumulator.state[perspective] == COMPUTED)
+ if (st->accumulator.computed[perspective])
{
if (next == nullptr)
return;
{
if (next == nullptr)
return;
ksq, st2, perspective, removed[1], added[1]);
// Mark the accumulators as computed.
ksq, st2, perspective, removed[1], added[1]);
// Mark the accumulators as computed.
- next->accumulator.state[perspective] = COMPUTED;
- pos.state()->accumulator.state[perspective] = COMPUTED;
+ next->accumulator.computed[perspective] = true;
+ pos.state()->accumulator.computed[perspective] = true;
// Now update the accumulators listed in states_to_update[], where the last element is a sentinel.
StateInfo *states_to_update[3] =
// Now update the accumulators listed in states_to_update[], where the last element is a sentinel.
StateInfo *states_to_update[3] =
{
// Refresh the accumulator
auto& accumulator = pos.state()->accumulator;
{
// Refresh the accumulator
auto& accumulator = pos.state()->accumulator;
- accumulator.state[perspective] = COMPUTED;
+ accumulator.computed[perspective] = true;
IndexList active;
FeatureSet::append_active_indices(pos, perspective, active);
IndexList active;
FeatureSet::append_active_indices(pos, perspective, active);
chess960 = isChess960;
thisThread = th;
set_state(st);
chess960 = isChess960;
thisThread = th;
set_state(st);
- st->accumulator.state[WHITE] = Eval::NNUE::INIT;
- st->accumulator.state[BLACK] = Eval::NNUE::INIT;
++st->pliesFromNull;
// Used by NNUE
++st->pliesFromNull;
// Used by NNUE
- st->accumulator.state[WHITE] = Eval::NNUE::EMPTY;
- st->accumulator.state[BLACK] = Eval::NNUE::EMPTY;
+ st->accumulator.computed[WHITE] = false;
+ st->accumulator.computed[BLACK] = false;
auto& dp = st->dirtyPiece;
dp.dirty_num = 1;
auto& dp = st->dirtyPiece;
dp.dirty_num = 1;
st->dirtyPiece.dirty_num = 0;
st->dirtyPiece.piece[0] = NO_PIECE; // Avoid checks in UpdateAccumulator()
st->dirtyPiece.dirty_num = 0;
st->dirtyPiece.piece[0] = NO_PIECE; // Avoid checks in UpdateAccumulator()
- st->accumulator.state[WHITE] = Eval::NNUE::EMPTY;
- st->accumulator.state[BLACK] = Eval::NNUE::EMPTY;
+ st->accumulator.computed[WHITE] = false;
+ st->accumulator.computed[BLACK] = false;
if (st->epSquare != SQ_NONE)
{
if (st->epSquare != SQ_NONE)
{