mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
simplify make_index()
passed non-regression STC: https://tests.stockfishchess.org/tests/view/68fdb409637acd2a11e72f11 LLR: 3.08 (-2.94,2.94) <-1.75,0.25> Total: 95008 W: 24837 L: 24677 D: 45494 Ptnml(0-2): 268, 10024, 26775, 10154, 283 closes https://github.com/official-stockfish/Stockfish/pull/6384 no functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
0351652995
commit
e9674a7888
@@ -29,9 +29,10 @@ namespace Stockfish::Eval::NNUE::Features {
|
|||||||
|
|
||||||
// Index of a feature for a given king position and another piece on some square
|
// Index of a feature for a given king position and another piece on some square
|
||||||
template<Color Perspective>
|
template<Color Perspective>
|
||||||
inline IndexType HalfKAv2_hm::make_index(Square s, Piece pc, Square ksq) {
|
IndexType HalfKAv2_hm::make_index(Square s, Piece pc, Square ksq) {
|
||||||
return IndexType((int(s) ^ OrientTBL[Perspective][ksq]) + PieceSquareIndex[Perspective][pc]
|
const IndexType flip = 56 * Perspective;
|
||||||
+ KingBuckets[Perspective][ksq]);
|
return (IndexType(s) ^ OrientTBL[ksq] ^ flip) + PieceSquareIndex[Perspective][pc]
|
||||||
|
+ KingBuckets[int(ksq) ^ flip];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of indices for active features
|
// Get a list of indices for active features
|
||||||
|
|||||||
@@ -75,45 +75,29 @@ class HalfKAv2_hm {
|
|||||||
|
|
||||||
#define B(v) (v * PS_NB)
|
#define B(v) (v * PS_NB)
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static constexpr int KingBuckets[COLOR_NB][SQUARE_NB] = {
|
static constexpr IndexType KingBuckets[SQUARE_NB] = {
|
||||||
{ B(28), B(29), B(30), B(31), B(31), B(30), B(29), B(28),
|
B(28), B(29), B(30), B(31), B(31), B(30), B(29), B(28),
|
||||||
B(24), B(25), B(26), B(27), B(27), B(26), B(25), B(24),
|
B(24), B(25), B(26), B(27), B(27), B(26), B(25), B(24),
|
||||||
B(20), B(21), B(22), B(23), B(23), B(22), B(21), B(20),
|
B(20), B(21), B(22), B(23), B(23), B(22), B(21), B(20),
|
||||||
B(16), B(17), B(18), B(19), B(19), B(18), B(17), B(16),
|
B(16), B(17), B(18), B(19), B(19), B(18), B(17), B(16),
|
||||||
B(12), B(13), B(14), B(15), B(15), B(14), B(13), B(12),
|
B(12), B(13), B(14), B(15), B(15), B(14), B(13), B(12),
|
||||||
B( 8), B( 9), B(10), B(11), B(11), B(10), B( 9), B( 8),
|
B( 8), B( 9), B(10), B(11), B(11), B(10), B( 9), B( 8),
|
||||||
B( 4), B( 5), B( 6), B( 7), B( 7), B( 6), B( 5), B( 4),
|
B( 4), B( 5), B( 6), B( 7), B( 7), B( 6), B( 5), B( 4),
|
||||||
B( 0), B( 1), B( 2), B( 3), B( 3), B( 2), B( 1), B( 0) },
|
B( 0), B( 1), B( 2), B( 3), B( 3), B( 2), B( 1), B( 0),
|
||||||
{ B( 0), B( 1), B( 2), B( 3), B( 3), B( 2), B( 1), B( 0),
|
|
||||||
B( 4), B( 5), B( 6), B( 7), B( 7), B( 6), B( 5), B( 4),
|
|
||||||
B( 8), B( 9), B(10), B(11), B(11), B(10), B( 9), B( 8),
|
|
||||||
B(12), B(13), B(14), B(15), B(15), B(14), B(13), B(12),
|
|
||||||
B(16), B(17), B(18), B(19), B(19), B(18), B(17), B(16),
|
|
||||||
B(20), B(21), B(22), B(23), B(23), B(22), B(21), B(20),
|
|
||||||
B(24), B(25), B(26), B(27), B(27), B(26), B(25), B(24),
|
|
||||||
B(28), B(29), B(30), B(31), B(31), B(30), B(29), B(28) }
|
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#undef B
|
#undef B
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Orient a square according to perspective (rotates by 180 for black)
|
// Orient a square according to perspective (rotates by 180 for black)
|
||||||
static constexpr int OrientTBL[COLOR_NB][SQUARE_NB] = {
|
static constexpr IndexType OrientTBL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