1818
1919// Definition of input features HalfKP of NNUE evaluation function
2020
21- #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED
22- #define NNUE_FEATURES_HALF_KP_H_INCLUDED
21+ #ifndef NNUE_FEATURES_HALF_KA_V2_H_INCLUDED
22+ #define NNUE_FEATURES_HALF_KA_V2_H_INCLUDED
2323
2424#include " ../nnue_common.h"
2525
@@ -32,33 +32,34 @@ namespace Stockfish {
3232
3333namespace Stockfish ::Eval::NNUE ::Features {
3434
35- // Feature HalfKP : Combination of the position of own king
36- // and the position of pieces other than kings
37- class HalfKP {
35+ // Feature HalfKAv2 : Combination of the position of own king
36+ // and the position of pieces
37+ class HalfKAv2 {
3838
3939 // unique number for each piece type on each square
4040 enum {
4141 PS_NONE = 0 ,
42- PS_W_PAWN = 1 ,
43- PS_B_PAWN = 1 * SQUARE_NB + 1 ,
44- PS_W_KNIGHT = 2 * SQUARE_NB + 1 ,
45- PS_B_KNIGHT = 3 * SQUARE_NB + 1 ,
46- PS_W_BISHOP = 4 * SQUARE_NB + 1 ,
47- PS_B_BISHOP = 5 * SQUARE_NB + 1 ,
48- PS_W_ROOK = 6 * SQUARE_NB + 1 ,
49- PS_B_ROOK = 7 * SQUARE_NB + 1 ,
50- PS_W_QUEEN = 8 * SQUARE_NB + 1 ,
51- PS_B_QUEEN = 9 * SQUARE_NB + 1 ,
52- PS_NB = 10 * SQUARE_NB + 1
42+ PS_W_PAWN = 0 ,
43+ PS_B_PAWN = 1 * SQUARE_NB ,
44+ PS_W_KNIGHT = 2 * SQUARE_NB ,
45+ PS_B_KNIGHT = 3 * SQUARE_NB ,
46+ PS_W_BISHOP = 4 * SQUARE_NB ,
47+ PS_B_BISHOP = 5 * SQUARE_NB ,
48+ PS_W_ROOK = 6 * SQUARE_NB ,
49+ PS_B_ROOK = 7 * SQUARE_NB ,
50+ PS_W_QUEEN = 8 * SQUARE_NB ,
51+ PS_B_QUEEN = 9 * SQUARE_NB ,
52+ PS_KING = 10 * SQUARE_NB ,
53+ PS_NB = 11 * SQUARE_NB
5354 };
5455
5556 static constexpr IndexType PieceSquareIndex[COLOR_NB ][PIECE_NB ] = {
5657 // convention: W - us, B - them
5758 // viewed from other side, W and B are reversed
58- { PS_NONE , PS_W_PAWN , PS_W_KNIGHT , PS_W_BISHOP , PS_W_ROOK , PS_W_QUEEN , PS_NONE , PS_NONE ,
59- PS_NONE , PS_B_PAWN , PS_B_KNIGHT , PS_B_BISHOP , PS_B_ROOK , PS_B_QUEEN , PS_NONE , PS_NONE },
60- { PS_NONE , PS_B_PAWN , PS_B_KNIGHT , PS_B_BISHOP , PS_B_ROOK , PS_B_QUEEN , PS_NONE , PS_NONE ,
61- PS_NONE , PS_W_PAWN , PS_W_KNIGHT , PS_W_BISHOP , PS_W_ROOK , PS_W_QUEEN , PS_NONE , PS_NONE }
59+ { PS_NONE , PS_W_PAWN , PS_W_KNIGHT , PS_W_BISHOP , PS_W_ROOK , PS_W_QUEEN , PS_KING , PS_NONE ,
60+ PS_NONE , PS_B_PAWN , PS_B_KNIGHT , PS_B_BISHOP , PS_B_ROOK , PS_B_QUEEN , PS_KING , PS_NONE },
61+ { PS_NONE , PS_B_PAWN , PS_B_KNIGHT , PS_B_BISHOP , PS_B_ROOK , PS_B_QUEEN , PS_KING , PS_NONE ,
62+ PS_NONE , PS_W_PAWN , PS_W_KNIGHT , PS_W_BISHOP , PS_W_ROOK , PS_W_QUEEN , PS_KING , PS_NONE }
6263 };
6364
6465 // Orient a square according to perspective (rotates by 180 for black)
@@ -69,17 +70,17 @@ namespace Stockfish::Eval::NNUE::Features {
6970
7071 public:
7172 // Feature name
72- static constexpr const char * Name = " HalfKP (Friend)" ;
73+ static constexpr const char * Name = " HalfKAv2 (Friend)" ;
7374
7475 // Hash value embedded in the evaluation file
75- static constexpr std::uint32_t HashValue = 0x5D69D5B8u ;
76+ static constexpr std::uint32_t HashValue = 0x5f234cb8u ;
7677
7778 // Number of feature dimensions
7879 static constexpr IndexType Dimensions =
7980 static_cast <IndexType>(SQUARE_NB ) * static_cast <IndexType>(PS_NB );
8081
81- // Maximum number of simultaneously active features. 30 because kins are not included.
82- static constexpr IndexType MaxActiveDimensions = 30 ;
82+ // Maximum number of simultaneously active features.
83+ static constexpr IndexType MaxActiveDimensions = 32 ;
8384
8485 // Get a list of indices for active features
8586 static void append_active_indices (
@@ -107,4 +108,4 @@ namespace Stockfish::Eval::NNUE::Features {
107108
108109} // namespace Stockfish::Eval::NNUE::Features
109110
110- #endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED
111+ #endif // #ifndef NNUE_FEATURES_HALF_KA_V2_H_INCLUDED
0 commit comments