mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 09:47:46 +00:00
55a6b2bdc4
# Conflicts: # README.md # Readme.md # src/Makefile # src/evaluate.cpp # src/evaluate.h # src/misc.cpp # src/nnue/architectures/halfkp_256x2-32-32.h # src/nnue/evaluate_nnue.cpp # src/nnue/evaluate_nnue.h # src/nnue/features/feature_set.h # src/nnue/features/features_common.h # src/nnue/features/half_kp.cpp # src/nnue/features/half_kp.h # src/nnue/features/index_list.h # src/nnue/layers/affine_transform.h # src/nnue/layers/clipped_relu.h # src/nnue/layers/input_slice.h # src/nnue/nnue_accumulator.h # src/nnue/nnue_architecture.h # src/nnue/nnue_common.h # src/nnue/nnue_feature_transformer.h # src/position.cpp # src/position.h # src/types.h # src/ucioption.cpp # stockfish.md
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
//Definition of input feature P of NNUE evaluation function
|
||
|
||
#if defined(EVAL_NNUE)
|
||
|
||
#include "p.h"
|
||
#include "index_list.h"
|
||
|
||
namespace Eval {
|
||
|
||
namespace NNUE {
|
||
|
||
namespace Features {
|
||
|
||
// Get a list of indices with a value of 1 among the features
|
||
void P::AppendActiveIndices(
|
||
const Position& pos, Color perspective, IndexList* active) {
|
||
// do nothing if array size is small to avoid compiler warning
|
||
if (RawFeatures::kMaxActiveDimensions < kMaxActiveDimensions) return;
|
||
|
||
const PieceSquare* pieces = (perspective == BLACK) ?
|
||
pos.eval_list()->piece_list_fb() :
|
||
pos.eval_list()->piece_list_fw();
|
||
for (PieceId i = PieceId::PIECE_ID_ZERO; i < PieceId::PIECE_ID_KING; ++i) {
|
||
if (pieces[i] != PieceSquare::PS_NONE) {
|
||
active->push_back(pieces[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Get a list of indices whose values have changed from the previous one in the feature quantity
|
||
void P::AppendChangedIndices(
|
||
const Position& pos, Color perspective,
|
||
IndexList* removed, IndexList* added) {
|
||
const auto& dp = pos.state()->dirtyPiece;
|
||
for (int i = 0; i < dp.dirty_num; ++i) {
|
||
if (dp.pieceId[i] >= PieceId::PIECE_ID_KING) continue;
|
||
if (dp.old_piece[i].from[perspective] != PieceSquare::PS_NONE) {
|
||
removed->push_back(dp.old_piece[i].from[perspective]);
|
||
}
|
||
if (dp.new_piece[i].from[perspective] != PieceSquare::PS_NONE) {
|
||
added->push_back(dp.new_piece[i].from[perspective]);
|
||
}
|
||
}
|
||
}
|
||
|
||
} // namespace Features
|
||
|
||
} // namespace NNUE
|
||
|
||
} // namespace Eval
|
||
|
||
#endif // defined(EVAL_NNUE)
|