- auto& dp = st->dirtyPiece;
- // The first condition tests whether an incremental update is
- // possible at all: if this side's king has moved, it is not possible.
- static_assert(std::is_same_v<RawFeatures::SortedTriggerSet,
- Features::CompileTimeList<Features::TriggerEvent, Features::TriggerEvent::kFriendKingMoved>>,
- "Current code assumes that only kFriendlyKingMoved refresh trigger is being used.");
- if ( dp.piece[0] == make_piece(c, KING)
- || (gain -= dp.dirty_num + 1) < 0)
+ // This governs when a full feature refresh is needed and how many
+ // updates are better than just one full refresh.
+ if ( FeatureSet::requires_refresh(st, perspective)
+ || (gain -= FeatureSet::update_cost(st) + 1) < 0)