Unify naming convention of the NNUE code

matches the rest of the stockfish code base

closes https://github.com/official-stockfish/Stockfish/pull/3437

No functional change
This commit is contained in:
Tomasz Sobczyk
2021-04-19 19:50:19 +02:00
committed by Joost VandeVondele
parent a7ab92ec25
commit fbbd4adc3c
17 changed files with 364 additions and 370 deletions

View File

@@ -36,7 +36,7 @@ namespace Stockfish::Eval::NNUE::Features {
return value == First || CompileTimeList<T, Remaining...>::Contains(value);
}
static constexpr std::array<T, sizeof...(Remaining) + 1>
kValues = {{First, Remaining...}};
Values = {{First, Remaining...}};
};
// Base class of feature set
@@ -51,16 +51,16 @@ namespace Stockfish::Eval::NNUE::Features {
public:
// Hash value embedded in the evaluation file
static constexpr std::uint32_t kHashValue = FeatureType::kHashValue;
static constexpr std::uint32_t HashValue = FeatureType::HashValue;
// Number of feature dimensions
static constexpr IndexType kDimensions = FeatureType::kDimensions;
static constexpr IndexType Dimensions = FeatureType::Dimensions;
// Maximum number of simultaneously active features
static constexpr IndexType kMaxActiveDimensions =
FeatureType::kMaxActiveDimensions;
static constexpr IndexType MaxActiveDimensions =
FeatureType::MaxActiveDimensions;
// Trigger for full calculation instead of difference calculation
using SortedTriggerSet =
CompileTimeList<TriggerEvent, FeatureType::kRefreshTrigger>;
static constexpr auto kRefreshTriggers = SortedTriggerSet::kValues;
CompileTimeList<TriggerEvent, FeatureType::RefreshTrigger>;
static constexpr auto RefreshTriggers = SortedTriggerSet::Values;
};

View File

@@ -33,11 +33,11 @@ namespace Stockfish::Eval::NNUE::Features {
// Trigger to perform full calculations instead of difference only
enum class TriggerEvent {
kFriendKingMoved // calculate full evaluation when own king moves
FriendKingMoved // calculate full evaluation when own king moves
};
enum class Side {
kFriend // side to move
Friend // side to move
};
} // namespace Stockfish::Eval::NNUE::Features

View File

@@ -30,12 +30,12 @@ namespace Stockfish::Eval::NNUE::Features {
// Index of a feature for a given king position and another piece on some square
inline IndexType make_index(Color perspective, Square s, Piece pc, Square ksq) {
return IndexType(orient(perspective, s) + kpp_board_index[perspective][pc] + PS_END * ksq);
return IndexType(orient(perspective, s) + PieceSquareIndex[perspective][pc] + PS_NB * ksq);
}
// Get a list of indices for active features
template <Side AssociatedKing>
void HalfKP<AssociatedKing>::AppendActiveIndices(
void HalfKP<AssociatedKing>::append_active_indices(
const Position& pos, Color perspective, IndexList* active) {
Square ksq = orient(perspective, pos.square<KING>(perspective));
@@ -48,7 +48,7 @@ namespace Stockfish::Eval::NNUE::Features {
}
// AppendChangedIndices() : get a list of indices for recently changed features
// append_changed_indices() : get a list of indices for recently changed features
// IMPORTANT: The `pos` in this function is pretty much useless as it
// is not always the position the features are updated to. The feature
@@ -67,7 +67,7 @@ namespace Stockfish::Eval::NNUE::Features {
// the current leaf position (the position after the move).
template <Side AssociatedKing>
void HalfKP<AssociatedKing>::AppendChangedIndices(
void HalfKP<AssociatedKing>::append_changed_indices(
const Position& pos, const DirtyPiece& dp, Color perspective,
IndexList* removed, IndexList* added) {
@@ -82,6 +82,6 @@ namespace Stockfish::Eval::NNUE::Features {
}
}
template class HalfKP<Side::kFriend>;
template class HalfKP<Side::Friend>;
} // namespace Stockfish::Eval::NNUE::Features

View File

@@ -33,25 +33,25 @@ namespace Stockfish::Eval::NNUE::Features {
public:
// Feature name
static constexpr const char* kName = "HalfKP(Friend)";
static constexpr const char* Name = "HalfKP(Friend)";
// Hash value embedded in the evaluation file
static constexpr std::uint32_t kHashValue =
0x5D69D5B9u ^ (AssociatedKing == Side::kFriend);
static constexpr std::uint32_t HashValue =
0x5D69D5B9u ^ (AssociatedKing == Side::Friend);
// Number of feature dimensions
static constexpr IndexType kDimensions =
static_cast<IndexType>(SQUARE_NB) * static_cast<IndexType>(PS_END);
static constexpr IndexType Dimensions =
static_cast<IndexType>(SQUARE_NB) * static_cast<IndexType>(PS_NB);
// Maximum number of simultaneously active features
static constexpr IndexType kMaxActiveDimensions = 30; // Kings don't count
static constexpr IndexType MaxActiveDimensions = 30; // Kings don't count
// Trigger for full calculation instead of difference calculation
static constexpr TriggerEvent kRefreshTrigger = TriggerEvent::kFriendKingMoved;
static constexpr TriggerEvent RefreshTrigger = TriggerEvent::FriendKingMoved;
// Get a list of indices for active features
static void AppendActiveIndices(const Position& pos, Color perspective,
IndexList* active);
static void append_active_indices(const Position& pos, Color perspective,
IndexList* active);
// Get a list of indices for recently changed features
static void AppendChangedIndices(const Position& pos, const DirtyPiece& dp, Color perspective,
IndexList* removed, IndexList* added);
static void append_changed_indices(const Position& pos, const DirtyPiece& dp, Color perspective,
IndexList* removed, IndexList* added);
};
} // namespace Stockfish::Eval::NNUE::Features

View File

@@ -56,7 +56,7 @@ namespace Stockfish::Eval::NNUE::Features {
//Type of feature index list
class IndexList
: public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
: public ValueList<IndexType, RawFeatures::MaxActiveDimensions> {
};
} // namespace Stockfish::Eval::NNUE::Features