From: Fabian Fichter Date: Sat, 19 Jun 2021 14:03:25 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=1aa002c5e052b139732d6049c85ebbf56b221a3a;p=fairystockfish.git Merge official-stockfish/master No functional change. --- 1aa002c5e052b139732d6049c85ebbf56b221a3a diff --cc src/nnue/architectures/halfkp_shogi_256x2-32-32.h index 935e1ad,0000000..919551b mode 100644,000000..100644 --- a/src/nnue/architectures/halfkp_shogi_256x2-32-32.h +++ b/src/nnue/architectures/halfkp_shogi_256x2-32-32.h @@@ -1,60 -1,0 +1,60 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +// Definition of input features and network structure used in NNUE evaluation function + +#ifndef NNUE_HALFKP_SHOGI_256X2_32_32_H_INCLUDED +#define NNUE_HALFKP_SHOGI_256X2_32_32_H_INCLUDED + +#include "../features/feature_set.h" +#include "../features/half_kp_shogi.h" + +#include "../layers/input_slice.h" +#include "../layers/affine_transform.h" +#include "../layers/clipped_relu.h" + +namespace Stockfish::Eval::NNUE::Features { +// Alias for compatibility with upstream code +template +using HalfKP = HalfKPShogi; +} + +namespace Stockfish::Eval::NNUE { + +// Input features used in evaluation function +using RawFeatures = Features::FeatureSet< - Features::HalfKPShogi>; ++ Features::HalfKPShogi>; + +// Number of input feature dimensions after conversion - constexpr IndexType kTransformedFeatureDimensions = 256; ++constexpr IndexType TransformedFeatureDimensions = 256; + +namespace Layers { + +// Define network structure - using InputLayer = InputSlice; ++using InputLayer = InputSlice; +using HiddenLayer1 = ClippedReLU>; +using HiddenLayer2 = ClippedReLU>; +using OutputLayer = AffineTransform; + +} // namespace Layers + +using Network = Layers::OutputLayer; + +} // namespace Stockfish::Eval::NNUE + +#endif // #ifndef NNUE_HALFKP_SHOGI_256X2_32_32_H_INCLUDED diff --cc src/nnue/architectures/halfkp_variants_256x2-32-32.h index d0aca10,0000000..f01c2fd mode 100644,000000..100644 --- a/src/nnue/architectures/halfkp_variants_256x2-32-32.h +++ b/src/nnue/architectures/halfkp_variants_256x2-32-32.h @@@ -1,60 -1,0 +1,60 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +// Definition of input features and network structure used in NNUE evaluation function + +#ifndef NNUE_HALFKP_VARIANTS_256X2_32_32_H_INCLUDED +#define NNUE_HALFKP_VARIANTS_256X2_32_32_H_INCLUDED + +#include "../features/feature_set.h" +#include "../features/half_kp_variants.h" + +#include "../layers/input_slice.h" +#include "../layers/affine_transform.h" +#include "../layers/clipped_relu.h" + +namespace Stockfish::Eval::NNUE::Features { +// Alias for compatibility with upstream code +template +using HalfKP = HalfKPVariants; +} + +namespace Stockfish::Eval::NNUE { + +// Input features used in evaluation function +using RawFeatures = Features::FeatureSet< - Features::HalfKPVariants>; ++ Features::HalfKPVariants>; + +// Number of input feature dimensions after conversion - constexpr IndexType kTransformedFeatureDimensions = 256; ++constexpr IndexType TransformedFeatureDimensions = 256; + +namespace Layers { + +// Define network structure - using InputLayer = InputSlice; ++using InputLayer = InputSlice; +using HiddenLayer1 = ClippedReLU>; +using HiddenLayer2 = ClippedReLU>; +using OutputLayer = AffineTransform; + +} // namespace Layers + +using Network = Layers::OutputLayer; + +} // namespace Stockfish::Eval::NNUE + +#endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED diff --cc src/nnue/features/half_kp.cpp index 10e5d75,5c7538d..8fe1ec6 --- a/src/nnue/features/half_kp.cpp +++ b/src/nnue/features/half_kp.cpp @@@ -40,7 -35,7 +40,7 @@@ namespace Stockfish::Eval::NNUE::Featur // Get a list of indices for active features template - void HalfKPChess::AppendActiveIndices( - void HalfKP::append_active_indices( ++ void HalfKPChess::append_active_indices( const Position& pos, Color perspective, IndexList* active) { Square ksq = orient(perspective, pos.square(perspective)); @@@ -72,7 -67,7 +72,7 @@@ // the current leaf position (the position after the move). template - void HalfKPChess::AppendChangedIndices( - void HalfKP::append_changed_indices( ++ void HalfKPChess::append_changed_indices( const Position& pos, const DirtyPiece& dp, Color perspective, IndexList* removed, IndexList* added) { @@@ -87,6 -82,6 +87,6 @@@ } } - template class HalfKPChess; - template class HalfKP; ++ template class HalfKPChess; } // namespace Stockfish::Eval::NNUE::Features diff --cc src/nnue/features/half_kp.h index b6eb752,14efb08..995023f --- a/src/nnue/features/half_kp.h +++ b/src/nnue/features/half_kp.h @@@ -33,25 -33,25 +33,25 @@@ namespace Stockfish::Eval::NNUE::Featur 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(SQUARE_NB_CHESS) * static_cast(PS_END); + static constexpr IndexType Dimensions = - static_cast(SQUARE_NB) * static_cast(PS_NB); ++ static_cast(SQUARE_NB_CHESS) * static_cast(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 diff --cc src/nnue/features/half_kp_shogi.cpp index 5fc920e,0000000..fbadfe5 mode 100644,000000..100644 --- a/src/nnue/features/half_kp_shogi.cpp +++ b/src/nnue/features/half_kp_shogi.cpp @@@ -1,98 -1,0 +1,98 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//Definition of input features HalfKP of NNUE evaluation function + +#include "half_kp_shogi.h" +#include "index_list.h" + +namespace Stockfish::Eval::NNUE::Features { + + constexpr Square rotate(Square s) { + return Square(SQUARE_NB_SHOGI - 1 - int(s)); + } + + constexpr Square to_shogi_square(Square s) { + return Square((8 - s % 12) * 9 + 8 - s / 12); + } + + // Orient a square according to perspective (rotates by 180 for black) + inline Square orient(Color perspective, Square s) { + return perspective == WHITE ? to_shogi_square(s) : rotate(to_shogi_square(s)); + } + + // 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) + shogi_kpp_board_index[perspective][pc] + SHOGI_PS_END * ksq); ++ return IndexType(orient(perspective, s) + PieceSquareIndexShogi[perspective][pc] + SHOGI_PS_END * ksq); + } + + // Index of a feature for a given king position and hand piece + inline IndexType make_index(Color perspective, Color c, int hand_index, PieceType pt, Square ksq) { + Color color = (c == perspective) ? WHITE : BLACK; - return IndexType(hand_index + shogi_kpp_hand_index[color][pt] + SHOGI_PS_END * ksq); ++ return IndexType(hand_index + PieceSquareIndexShogiHand[color][pt] + SHOGI_PS_END * ksq); + } + + // Get a list of indices for active features + template - void HalfKPShogi::AppendActiveIndices( ++ void HalfKPShogi::append_active_indices( + const Position& pos, Color perspective, IndexList* active) { + + Square ksq = orient(perspective, pos.square(perspective)); + Bitboard bb = pos.pieces() & ~pos.pieces(KING); + while (bb) { + Square s = pop_lsb(bb); + active->push_back(make_index(perspective, s, pos.piece_on(s), ksq)); + } + + // Indices for pieces in hand + for (Color c : {WHITE, BLACK}) + for (PieceType pt : pos.piece_types()) + for (int i = 0; i < pos.count_in_hand(c, pt); i++) + active->push_back(make_index(perspective, c, i, pt, ksq)); + } + + // Get a list of indices for recently changed features + template - void HalfKPShogi::AppendChangedIndices( ++ void HalfKPShogi::append_changed_indices( + const Position& pos, const DirtyPiece& dp, Color perspective, + IndexList* removed, IndexList* added) { + + Square ksq = orient(perspective, pos.square(perspective)); + for (int i = 0; i < dp.dirty_num; ++i) { + Piece pc = dp.piece[i]; + if (type_of(pc) == KING) continue; + if (dp.from[i] != SQ_NONE) + removed->push_back(make_index(perspective, dp.from[i], pc, ksq)); + else if (dp.dirty_num == 1) + { + Piece handPc = dp.handPiece[i]; + removed->push_back(make_index(perspective, color_of(handPc), pos.count_in_hand(color_of(handPc), type_of(handPc)), type_of(handPc), ksq)); + } + if (dp.to[i] != SQ_NONE) + added->push_back(make_index(perspective, dp.to[i], pc, ksq)); + else if (i == 1) + { + Piece handPc = dp.handPiece[i]; + added->push_back(make_index(perspective, color_of(handPc), pos.count_in_hand(color_of(handPc), type_of(handPc)) - 1, type_of(handPc), ksq)); + } + } + } + - template class HalfKPShogi; ++ template class HalfKPShogi; + +} // namespace Stockfish::Eval::NNUE::Features diff --cc src/nnue/features/half_kp_shogi.h index 3e25339,0000000..343d2d1 mode 100644,000000..100644 --- a/src/nnue/features/half_kp_shogi.h +++ b/src/nnue/features/half_kp_shogi.h @@@ -1,59 -1,0 +1,59 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//Definition of input features HalfKP of NNUE evaluation function + +#ifndef NNUE_FEATURES_HALF_KP_SHOGI_H_INCLUDED +#define NNUE_FEATURES_HALF_KP_SHOGI_H_INCLUDED + +#include "../../evaluate.h" +#include "features_common.h" + +namespace Stockfish::Eval::NNUE::Features { + + // Feature HalfKP: Combination of the position of own king + // and the position of pieces other than kings + template + class HalfKPShogi { + + 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 constexpr IndexType Dimensions = + static_cast(SQUARE_NB_SHOGI) * static_cast(SHOGI_PS_END); + // Maximum number of simultaneously active features - static constexpr IndexType kMaxActiveDimensions = 38; // Kings don't count ++ static constexpr IndexType MaxActiveDimensions = 38; // 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 + +#endif // #ifndef NNUE_FEATURES_HALF_KP_SHOGI_H_INCLUDED diff --cc src/nnue/features/half_kp_variants.cpp index 0eca178,0000000..a149823 mode 100644,000000..100644 --- a/src/nnue/features/half_kp_variants.cpp +++ b/src/nnue/features/half_kp_variants.cpp @@@ -1,96 -1,0 +1,96 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//Definition of input features HalfKP of NNUE evaluation function + +#include "half_kp_variants.h" +#include "index_list.h" + +#ifdef LARGEBOARDS +#include "half_kp_shogi.h" +#endif + +namespace Stockfish::Eval::NNUE::Features { + + // Map square to numbering on 8x8 board + constexpr Square to_chess_square(Square s) { + return Square(s - rank_of(s) * (FILE_MAX - FILE_H)); + } + + // Orient a square according to perspective (rotates by 180 for black) + inline Square orient(const Position& pos, Color perspective, Square s) { + return to_chess_square( perspective == WHITE || (pos.capture_the_flag(BLACK) & Rank8BB) ? s + : flip_rank(flip_file(s, pos.max_file()), pos.max_rank())); + } + + // Index of a feature for a given king position and another piece on some square + inline IndexType make_index(const Position& pos, Color perspective, Square s, Piece pc, Square ksq) { - return IndexType(orient(pos, perspective, s) + kpp_board_index[perspective][pc] + PS_END * ksq); ++ return IndexType(orient(pos, perspective, s) + PieceSquareIndex[perspective][pc] + PS_NB * ksq); + } + + // Get a list of indices for active features + template - void HalfKPVariants::AppendActiveIndices( ++ void HalfKPVariants::append_active_indices( + const Position& pos, Color perspective, IndexList* active) { + + // Re-route to shogi features +#ifdef LARGEBOARDS + if (currentNnueFeatures == NNUE_SHOGI) + { - assert(HalfKPShogi::kDimensions <= kDimensions); - return HalfKPShogi::AppendActiveIndices(pos, perspective, active); ++ assert(HalfKPShogi::Dimensions <= Dimensions); ++ return HalfKPShogi::append_active_indices(pos, perspective, active); + } +#endif + + Square ksq = orient(pos, perspective, pos.square(perspective, pos.nnue_king())); + Bitboard bb = pos.pieces() & ~pos.pieces(pos.nnue_king()); + while (bb) { + Square s = pop_lsb(bb); + active->push_back(make_index(pos, perspective, s, pos.piece_on(s), ksq)); + } + } + + // Get a list of indices for recently changed features + template - void HalfKPVariants::AppendChangedIndices( ++ void HalfKPVariants::append_changed_indices( + const Position& pos, const DirtyPiece& dp, Color perspective, + IndexList* removed, IndexList* added) { + + // Re-route to shogi features +#ifdef LARGEBOARDS + if (currentNnueFeatures == NNUE_SHOGI) + { - assert(HalfKPShogi::kDimensions <= kDimensions); - return HalfKPShogi::AppendChangedIndices(pos, dp, perspective, removed, added); ++ assert(HalfKPShogi::Dimensions <= Dimensions); ++ return HalfKPShogi::append_changed_indices(pos, dp, perspective, removed, added); + } +#endif + + Square ksq = orient(pos, perspective, pos.square(perspective, pos.nnue_king())); + for (int i = 0; i < dp.dirty_num; ++i) { + Piece pc = dp.piece[i]; + if (type_of(pc) == pos.nnue_king()) continue; + if (dp.from[i] != SQ_NONE) + removed->push_back(make_index(pos, perspective, dp.from[i], pc, ksq)); + if (dp.to[i] != SQ_NONE) + added->push_back(make_index(pos, perspective, dp.to[i], pc, ksq)); + } + } + - template class HalfKPVariants; ++ template class HalfKPVariants; + +} // namespace Stockfish::Eval::NNUE::Features diff --cc src/nnue/features/half_kp_variants.h index 09e5b94,0000000..f5720d4 mode 100644,000000..100644 --- a/src/nnue/features/half_kp_variants.h +++ b/src/nnue/features/half_kp_variants.h @@@ -1,63 -1,0 +1,63 @@@ +/* + Stockfish, a UCI chess playing engine derived from Glaurung 2.1 + Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file) + + Stockfish is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Stockfish is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//Definition of input features HalfKP of NNUE evaluation function + +#ifndef NNUE_FEATURES_HALF_KP_VARIANTS_H_INCLUDED +#define NNUE_FEATURES_HALF_KP_VARIANTS_H_INCLUDED + +#include "../../evaluate.h" +#include "features_common.h" + +namespace Stockfish::Eval::NNUE::Features { + + // Feature HalfKP: Combination of the position of own king + // and the position of pieces other than kings + template + class HalfKPVariants { + + 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 constexpr IndexType Dimensions = +#ifdef LARGEBOARDS + static_cast(SQUARE_NB_SHOGI) * static_cast(SHOGI_PS_END); +#else - static_cast(SQUARE_NB_CHESS) * static_cast(PS_END); ++ static_cast(SQUARE_NB_CHESS) * static_cast(PS_NB); +#endif + // Maximum number of simultaneously active features - static constexpr IndexType kMaxActiveDimensions = 64; // Kings don't count ++ static constexpr IndexType MaxActiveDimensions = 64; // 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 + +#endif // #ifndef NNUE_FEATURES_HALF_KP_VARIANTS_H_INCLUDED diff --cc src/nnue/nnue_common.h index 0b31791,20eb27d..35bbea2 --- a/src/nnue/nnue_common.h +++ b/src/nnue/nnue_common.h @@@ -75,189 -75,26 +75,186 @@@ namespace Stockfish::Eval::NNUE enum { PS_NONE = 0, PS_W_PAWN = 1, - PS_B_PAWN = 1 * SQUARE_NB + 1, - PS_W_KNIGHT = 2 * SQUARE_NB + 1, - PS_B_KNIGHT = 3 * SQUARE_NB + 1, - PS_W_BISHOP = 4 * SQUARE_NB + 1, - PS_B_BISHOP = 5 * SQUARE_NB + 1, - PS_W_ROOK = 6 * SQUARE_NB + 1, - PS_B_ROOK = 7 * SQUARE_NB + 1, - PS_W_QUEEN = 8 * SQUARE_NB + 1, - PS_B_QUEEN = 9 * SQUARE_NB + 1, - PS_NB = 10 * SQUARE_NB + 1 + PS_B_PAWN = 1 * SQUARE_NB_CHESS + 1, + PS_W_KNIGHT = 2 * SQUARE_NB_CHESS + 1, + PS_B_KNIGHT = 3 * SQUARE_NB_CHESS + 1, + PS_W_BISHOP = 4 * SQUARE_NB_CHESS + 1, + PS_B_BISHOP = 5 * SQUARE_NB_CHESS + 1, + PS_W_ROOK = 6 * SQUARE_NB_CHESS + 1, + PS_B_ROOK = 7 * SQUARE_NB_CHESS + 1, + PS_W_QUEEN = 8 * SQUARE_NB_CHESS + 1, + PS_B_QUEEN = 9 * SQUARE_NB_CHESS + 1, - PS_W_KING = 10 * SQUARE_NB_CHESS + 1, - PS_END = PS_W_KING, // pieces without kings (pawns included) - PS_B_KING = 11 * SQUARE_NB_CHESS + 1, - PS_END2 = 12 * SQUARE_NB_CHESS + 1 ++ PS_NB = 10 * SQUARE_NB_CHESS + 1, }; + enum { + SHOGI_HAND_W_PAWN = 1, + SHOGI_HAND_B_PAWN = 20, + SHOGI_HAND_W_LANCE = 39, + SHOGI_HAND_B_LANCE = 44, + SHOGI_HAND_W_KNIGHT = 49, + SHOGI_HAND_B_KNIGHT = 54, + SHOGI_HAND_W_SILVER = 59, + SHOGI_HAND_B_SILVER = 64, + SHOGI_HAND_W_GOLD = 69, + SHOGI_HAND_B_GOLD = 74, + SHOGI_HAND_W_BISHOP = 79, + SHOGI_HAND_B_BISHOP = 82, + SHOGI_HAND_W_ROOK = 85, + SHOGI_HAND_B_ROOK = 88, + SHOGI_HAND_END = 90, + + SHOGI_PS_W_PAWN = SHOGI_HAND_END, + SHOGI_PS_B_PAWN = 1 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_LANCE = 2 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_LANCE = 3 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_KNIGHT = 4 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_KNIGHT = 5 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_SILVER = 6 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_SILVER = 7 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_GOLD = 8 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_GOLD = 9 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_BISHOP = 10 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_BISHOP = 11 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_HORSE = 12 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_HORSE = 13 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_ROOK = 14 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_ROOK = 15 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_DRAGON = 16 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_B_DRAGON = 17 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_W_KING = 18 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_END = SHOGI_PS_W_KING, // pieces without kings (pawns included) + SHOGI_PS_B_KING = 19 * SQUARE_NB_SHOGI + SHOGI_HAND_END, + SHOGI_PS_END2 = 20 * SQUARE_NB_SHOGI + SHOGI_HAND_END + }; + - constexpr uint32_t shogi_kpp_board_index[COLOR_NB][PIECE_NB] = { ++ constexpr uint32_t PieceSquareIndexShogi[COLOR_NB][PIECE_NB] = { + // convention: W - us, B - them + // viewed from other side, W and B are reversed + { + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_BISHOP, SHOGI_PS_W_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_PS_W_SILVER, PS_NONE, SHOGI_PS_W_DRAGON, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_PAWN, SHOGI_PS_W_LANCE, SHOGI_PS_W_KNIGHT, SHOGI_PS_W_GOLD, SHOGI_PS_W_HORSE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_KING, + + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_BISHOP, SHOGI_PS_B_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_PS_B_SILVER, PS_NONE, SHOGI_PS_B_DRAGON, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_PAWN, SHOGI_PS_B_LANCE, SHOGI_PS_B_KNIGHT, SHOGI_PS_B_GOLD, SHOGI_PS_B_HORSE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_KING + }, + + { + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_BISHOP, SHOGI_PS_B_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_PS_B_SILVER, PS_NONE, SHOGI_PS_B_DRAGON, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_PAWN, SHOGI_PS_B_LANCE, SHOGI_PS_B_KNIGHT, SHOGI_PS_B_GOLD, SHOGI_PS_B_HORSE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_B_KING, + + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_BISHOP, SHOGI_PS_W_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_PS_W_SILVER, PS_NONE, SHOGI_PS_W_DRAGON, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_PAWN, SHOGI_PS_W_LANCE, SHOGI_PS_W_KNIGHT, SHOGI_PS_W_GOLD, SHOGI_PS_W_HORSE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, SHOGI_PS_W_KING + } + }; - static_assert(shogi_kpp_board_index[WHITE][make_piece(WHITE, SHOGI_PAWN)] == SHOGI_PS_W_PAWN); - static_assert(shogi_kpp_board_index[WHITE][make_piece(WHITE, KING)] == SHOGI_PS_W_KING); - static_assert(shogi_kpp_board_index[WHITE][make_piece(BLACK, SHOGI_PAWN)] == SHOGI_PS_B_PAWN); - static_assert(shogi_kpp_board_index[WHITE][make_piece(BLACK, KING)] == SHOGI_PS_B_KING); ++ static_assert(PieceSquareIndexShogi[WHITE][make_piece(WHITE, SHOGI_PAWN)] == SHOGI_PS_W_PAWN); ++ static_assert(PieceSquareIndexShogi[WHITE][make_piece(WHITE, KING)] == SHOGI_PS_W_KING); ++ static_assert(PieceSquareIndexShogi[WHITE][make_piece(BLACK, SHOGI_PAWN)] == SHOGI_PS_B_PAWN); ++ static_assert(PieceSquareIndexShogi[WHITE][make_piece(BLACK, KING)] == SHOGI_PS_B_KING); + - constexpr uint32_t shogi_kpp_hand_index[COLOR_NB][PIECE_TYPE_NB] = { ++ constexpr uint32_t PieceSquareIndexShogiHand[COLOR_NB][PIECE_TYPE_NB] = { + // convention: W - us, B - them + // viewed from other side, W and B are reversed + { + PS_NONE, PS_NONE, PS_NONE, SHOGI_HAND_W_BISHOP, SHOGI_HAND_W_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_HAND_W_SILVER, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_HAND_W_PAWN, SHOGI_HAND_W_LANCE, SHOGI_HAND_W_KNIGHT, SHOGI_HAND_W_GOLD, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE + }, + + { + PS_NONE, PS_NONE, PS_NONE, SHOGI_HAND_B_BISHOP, SHOGI_HAND_B_ROOK, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, SHOGI_HAND_B_SILVER, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, SHOGI_HAND_B_PAWN, SHOGI_HAND_B_LANCE, SHOGI_HAND_B_KNIGHT, SHOGI_HAND_B_GOLD, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE + } + }; - static_assert(shogi_kpp_hand_index[WHITE][SHOGI_PAWN] == SHOGI_HAND_W_PAWN); - static_assert(shogi_kpp_hand_index[WHITE][GOLD] == SHOGI_HAND_W_GOLD); - static_assert(shogi_kpp_hand_index[BLACK][SHOGI_PAWN] == SHOGI_HAND_B_PAWN); - static_assert(shogi_kpp_hand_index[BLACK][GOLD] == SHOGI_HAND_B_GOLD); ++ static_assert(PieceSquareIndexShogiHand[WHITE][SHOGI_PAWN] == SHOGI_HAND_W_PAWN); ++ static_assert(PieceSquareIndexShogiHand[WHITE][GOLD] == SHOGI_HAND_W_GOLD); ++ static_assert(PieceSquareIndexShogiHand[BLACK][SHOGI_PAWN] == SHOGI_HAND_B_PAWN); ++ static_assert(PieceSquareIndexShogiHand[BLACK][GOLD] == SHOGI_HAND_B_GOLD); + - constexpr uint32_t kpp_board_index[COLOR_NB][PIECE_NB] = { + constexpr uint32_t PieceSquareIndex[COLOR_NB][PIECE_NB] = { // convention: W - us, B - them // viewed from other side, W and B are reversed - { PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_W_BISHOP, PS_W_ROOK, PS_W_QUEEN, PS_NONE, PS_NONE, - PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_B_BISHOP, PS_B_ROOK, PS_B_QUEEN, PS_NONE, PS_NONE }, - { PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_B_BISHOP, PS_B_ROOK, PS_B_QUEEN, PS_NONE, PS_NONE, - PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_W_BISHOP, PS_W_ROOK, PS_W_QUEEN, PS_NONE, PS_NONE } + { + PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_W_BISHOP, PS_W_ROOK, PS_W_QUEEN, PS_W_QUEEN, PS_W_BISHOP, + PS_W_BISHOP, PS_W_BISHOP, PS_W_QUEEN, PS_W_QUEEN, PS_NONE, PS_NONE, PS_W_QUEEN, PS_W_KNIGHT, + PS_W_BISHOP, PS_W_KNIGHT, PS_W_ROOK, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_W_BISHOP, PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, - PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_W_KING, ++ PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + + PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_B_BISHOP, PS_B_ROOK, PS_B_QUEEN, PS_B_QUEEN, PS_B_BISHOP, + PS_B_BISHOP, PS_B_BISHOP, PS_B_QUEEN, PS_B_QUEEN, PS_NONE, PS_NONE, PS_B_QUEEN, PS_B_KNIGHT, + PS_B_BISHOP, PS_B_KNIGHT, PS_B_ROOK, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_B_BISHOP, PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, - PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_B_KING, ++ PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + }, + + { + PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_B_BISHOP, PS_B_ROOK, PS_B_QUEEN, PS_B_QUEEN, PS_B_BISHOP, + PS_B_BISHOP, PS_B_BISHOP, PS_B_QUEEN, PS_B_QUEEN, PS_NONE, PS_NONE, PS_B_QUEEN, PS_B_KNIGHT, + PS_B_BISHOP, PS_B_KNIGHT, PS_B_ROOK, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_B_BISHOP, PS_NONE, PS_B_PAWN, PS_B_KNIGHT, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, - PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_B_KING, ++ PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + + PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_W_BISHOP, PS_W_ROOK, PS_W_QUEEN, PS_W_QUEEN, PS_W_BISHOP, + PS_W_BISHOP, PS_W_BISHOP, PS_W_QUEEN, PS_W_QUEEN, PS_NONE, PS_NONE, PS_W_QUEEN, PS_W_KNIGHT, + PS_W_BISHOP, PS_W_KNIGHT, PS_W_ROOK, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_W_BISHOP, PS_NONE, PS_W_PAWN, PS_W_KNIGHT, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, - PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_W_KING, ++ PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, PS_NONE, + } }; + // Check that the fragile array definition is correct - static_assert(kpp_board_index[WHITE][make_piece(WHITE, PAWN)] == PS_W_PAWN); - static_assert(kpp_board_index[WHITE][make_piece(WHITE, KING)] == PS_W_KING); - static_assert(kpp_board_index[WHITE][make_piece(BLACK, PAWN)] == PS_B_PAWN); - static_assert(kpp_board_index[WHITE][make_piece(BLACK, KING)] == PS_B_KING); ++ static_assert(PieceSquareIndex[WHITE][make_piece(WHITE, PAWN)] == PS_W_PAWN); ++ static_assert(PieceSquareIndex[WHITE][make_piece(WHITE, KING)] == PS_NONE); ++ static_assert(PieceSquareIndex[WHITE][make_piece(BLACK, PAWN)] == PS_B_PAWN); ++ static_assert(PieceSquareIndex[WHITE][make_piece(BLACK, KING)] == PS_NONE); + // Type of input feature after conversion using TransformedFeatureType = std::uint8_t; diff --cc src/nnue/nnue_feature_transformer.h index 6d07653,de4b493..4da475e --- a/src/nnue/nnue_feature_transformer.h +++ b/src/nnue/nnue_feature_transformer.h @@@ -110,14 -109,11 +109,14 @@@ namespace Stockfish::Eval::NNUE } // Read network parameters - bool ReadParameters(std::istream& stream) { - - for (std::size_t i = 0; i < kHalfDimensions; ++i) - biases_[i] = read_little_endian(stream); - for (std::size_t i = 0; i < kHalfDimensions * ( currentNnueFeatures == NNUE_SHOGI ? SQUARE_NB_SHOGI * SHOGI_PS_END - : currentNnueFeatures == NNUE_CHESS ? SQUARE_NB_CHESS * PS_END - : SQUARE_NB_CHESS * PS_END); ++i) - weights_[i] = read_little_endian(stream); + bool read_parameters(std::istream& stream) { ++ + for (std::size_t i = 0; i < HalfDimensions; ++i) + biases[i] = read_little_endian(stream); - for (std::size_t i = 0; i < HalfDimensions * InputDimensions; ++i) ++ for (std::size_t i = 0; i < HalfDimensions * ( currentNnueFeatures == NNUE_SHOGI ? SQUARE_NB_SHOGI * SHOGI_PS_END ++ : currentNnueFeatures == NNUE_CHESS ? SQUARE_NB_CHESS * PS_NB ++ : SQUARE_NB_CHESS * PS_NB); ++i) + weights[i] = read_little_endian(stream); return !stream.fail(); } @@@ -257,9 -251,9 +255,9 @@@ // The first condition tests whether an incremental update is // possible at all: if this side's king has moved, it is not possible. static_assert(std::is_same_v>, - "Current code assumes that only kFriendlyKingMoved refresh trigger is being used."); + Features::CompileTimeList>, + "Current code assumes that only FriendlyKingMoved refresh trigger is being used."); - if ( dp.piece[0] == make_piece(c, KING) + if ( dp.piece[0] == make_piece(c, pos.nnue_king()) || (gain -= dp.dirty_num + 1) < 0) break; next = st; diff --cc src/position.cpp index f275834,2b3be3f..1956d7d --- a/src/position.cpp +++ b/src/position.cpp @@@ -101,10 -79,10 +101,10 @@@ std::ostream& operator<<(std::ostream& && !pos.can_castle(ANY_CASTLING)) { StateInfo st; - ASSERT_ALIGNED(&st, Eval::NNUE::kCacheLineSize); + ASSERT_ALIGNED(&st, Eval::NNUE::CacheLineSize); Position p; - p.set(pos.fen(), pos.is_chess960(), &st, pos.this_thread()); + p.set(pos.variant(), pos.fen(), pos.is_chess960(), &st, pos.this_thread()); Tablebases::ProbeState s1, s2; Tablebases::WDLScore wdl = Tablebases::probe_wdl(p, &s1); int dtz = Tablebases::probe_dtz(p, &s2);