diff --git a/src/eval/nnue/features/half_kp.cpp b/src/eval/nnue/features/half_kp.cpp index 1741f3ce..5cd95637 100644 --- a/src/eval/nnue/features/half_kp.cpp +++ b/src/eval/nnue/features/half_kp.cpp @@ -42,7 +42,9 @@ void HalfKP::AppendActiveIndices( Square sq_target_k; GetPieces(pos, perspective, &pieces, &sq_target_k); for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) { - active->push_back(MakeIndex(sq_target_k, pieces[i])); + if (pieces[i] != Eval::BONA_PIECE_ZERO) { + active->push_back(MakeIndex(sq_target_k, pieces[i])); + } } } @@ -59,10 +61,14 @@ void HalfKP::AppendChangedIndices( if (dp.pieceNo[i] >= PIECE_NUMBER_KING) continue; const auto old_p = static_cast( dp.changed_piece[i].old_piece.from[perspective]); - removed->push_back(MakeIndex(sq_target_k, old_p)); + if (old_p != Eval::BONA_PIECE_ZERO) { + removed->push_back(MakeIndex(sq_target_k, old_p)); + } const auto new_p = static_cast( dp.changed_piece[i].new_piece.from[perspective]); - added->push_back(MakeIndex(sq_target_k, new_p)); + if (new_p != Eval::BONA_PIECE_ZERO) { + added->push_back(MakeIndex(sq_target_k, new_p)); + } } } diff --git a/src/eval/nnue/features/half_relative_kp.cpp b/src/eval/nnue/features/half_relative_kp.cpp index d0810df6..d62beea0 100644 --- a/src/eval/nnue/features/half_relative_kp.cpp +++ b/src/eval/nnue/features/half_relative_kp.cpp @@ -50,7 +50,9 @@ void HalfRelativeKP::AppendActiveIndices( GetPieces(pos, perspective, &pieces, &sq_target_k); for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) { if (pieces[i] >= fe_hand_end) { - active->push_back(MakeIndex(sq_target_k, pieces[i])); + if (pieces[i] != Eval::BONA_PIECE_ZERO) { + active->push_back(MakeIndex(sq_target_k, pieces[i])); + } } } } @@ -69,12 +71,16 @@ void HalfRelativeKP::AppendChangedIndices( const auto old_p = static_cast( dp.changed_piece[i].old_piece.from[perspective]); if (old_p >= fe_hand_end) { - removed->push_back(MakeIndex(sq_target_k, old_p)); + if (old_p != Eval::BONA_PIECE_ZERO) { + removed->push_back(MakeIndex(sq_target_k, old_p)); + } } const auto new_p = static_cast( dp.changed_piece[i].new_piece.from[perspective]); if (new_p >= fe_hand_end) { - added->push_back(MakeIndex(sq_target_k, new_p)); + if (new_p != Eval::BONA_PIECE_ZERO) { + added->push_back(MakeIndex(sq_target_k, new_p)); + } } } } diff --git a/src/eval/nnue/features/p.cpp b/src/eval/nnue/features/p.cpp index da1481cb..56bca0a4 100644 --- a/src/eval/nnue/features/p.cpp +++ b/src/eval/nnue/features/p.cpp @@ -21,7 +21,9 @@ void P::AppendActiveIndices( pos.eval_list()->piece_list_fb() : pos.eval_list()->piece_list_fw(); for (PieceNumber i = PIECE_NUMBER_ZERO; i < PIECE_NUMBER_KING; ++i) { - active->push_back(pieces[i]); + if (pieces[i] != Eval::BONA_PIECE_ZERO) { + active->push_back(pieces[i]); + } } } @@ -32,8 +34,12 @@ void P::AppendChangedIndices( const auto& dp = pos.state()->dirtyPiece; for (int i = 0; i < dp.dirty_num; ++i) { if (dp.pieceNo[i] >= PIECE_NUMBER_KING) continue; - removed->push_back(dp.changed_piece[i].old_piece.from[perspective]); - added->push_back(dp.changed_piece[i].new_piece.from[perspective]); + if (dp.changed_piece[i].old_piece.from[perspective] != Eval::BONA_PIECE_ZERO) { + removed->push_back(dp.changed_piece[i].old_piece.from[perspective]); + } + if (dp.changed_piece[i].new_piece.from[perspective] != Eval::BONA_PIECE_ZERO) { + added->push_back(dp.changed_piece[i].new_piece.from[perspective]); + } } }