- public:
- // Get a list of indices for active features
- template <typename IndexListType>
- static void AppendActiveIndices(
- const Position& pos, TriggerEvent trigger, IndexListType active[2]) {
-
- for (Color perspective : { WHITE, BLACK }) {
- Derived::CollectActiveIndices(
- pos, trigger, perspective, &active[perspective]);
- }
- }
-
- // Get a list of indices for recently changed features
- template <typename PositionType, typename IndexListType>
- static void AppendChangedIndices(
- const PositionType& pos, TriggerEvent trigger,
- IndexListType removed[2], IndexListType added[2], bool reset[2]) {
-
- const auto& dp = pos.state()->dirtyPiece;
- if (dp.dirty_num == 0) return;
-
- for (Color perspective : { WHITE, BLACK }) {
- reset[perspective] = false;
- switch (trigger) {
- case TriggerEvent::kFriendKingMoved:
- reset[perspective] =
- dp.pieceId[0] == PIECE_ID_KING + perspective;
- break;
- default:
- assert(false);
- break;
- }
- if (reset[perspective]) {
- Derived::CollectActiveIndices(
- pos, trigger, perspective, &added[perspective]);
- } else {
- Derived::CollectChangedIndices(
- pos, trigger, perspective,
- &removed[perspective], &added[perspective]);
- }
- }
- }