diff --git a/src/nnue/nnue_feature_transformer.h b/src/nnue/nnue_feature_transformer.h index b047f62c..8649d952 100644 --- a/src/nnue/nnue_feature_transformer.h +++ b/src/nnue/nnue_feature_transformer.h @@ -472,9 +472,8 @@ class FeatureTransformer { return st; } - // It computes the accumulator of the next position, or updates the - // current position's accumulator if CurrentOnly is true. - template + // Computes the accumulator of the next position. + template void update_accumulator_incremental(const Position& pos, StateInfo* computed) const { assert((computed->*accPtr).computed[Perspective]); assert(computed->next != nullptr); @@ -493,16 +492,10 @@ class FeatureTransformer { // feature set's update cost calculation to be correct and never allow // updates with more added/removed features than MaxActiveDimensions. FeatureSet::IndexList removed, added; + FeatureSet::append_changed_indices(ksq, computed->next->dirtyPiece, removed, + added); - if constexpr (CurrentOnly) - for (StateInfo* st = pos.state(); st != computed; st = st->previous) - FeatureSet::append_changed_indices(ksq, st->dirtyPiece, removed, - added); - else - FeatureSet::append_changed_indices(ksq, computed->next->dirtyPiece, - removed, added); - - StateInfo* next = CurrentOnly ? pos.state() : computed->next; + StateInfo* next = computed->next; assert(!(next->*accPtr).computed[Perspective]); #ifdef VECTOR @@ -665,8 +658,8 @@ class FeatureTransformer { (next->*accPtr).computed[Perspective] = true; - if (!CurrentOnly && next != pos.state()) - update_accumulator_incremental(pos, next); + if (next != pos.state()) + update_accumulator_incremental(pos, next); } template @@ -844,7 +837,7 @@ class FeatureTransformer { StateInfo* oldest = try_find_computed_accumulator(pos); if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state()) - update_accumulator_incremental(pos, oldest); + update_accumulator_incremental(pos, oldest); else update_accumulator_refresh_cache(pos, cache); } @@ -858,7 +851,7 @@ class FeatureTransformer { if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state()) // Start from the oldest computed accumulator, update all the // accumulators up to the current position. - update_accumulator_incremental(pos, oldest); + update_accumulator_incremental(pos, oldest); else update_accumulator_refresh_cache(pos, cache); }