void HalfKP<AssociatedKing>::AppendActiveIndices(
const Position& pos, Color perspective, IndexList* active) {
- Square ksq = orient(pos, perspective, pos.square<KING>(perspective));
- Bitboard bb = pos.pieces() & ~pos.pieces(KING);
+ 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));
const Position& pos, const DirtyPiece& dp, Color perspective,
IndexList* removed, IndexList* added) {
- Square ksq = orient(pos, perspective, pos.square<KING>(perspective));
+ 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) == KING) continue;
+ 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)
static_assert(std::is_same_v<RawFeatures::SortedTriggerSet,
Features::CompileTimeList<Features::TriggerEvent, Features::TriggerEvent::kFriendKingMoved>>,
"Current code assumes that only kFriendlyKingMoved 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;
if (type_of(bpc) != PAWN)
st->nonPawnMaterial[bc] -= PieceValue[MG][bpc];
+ if (Eval::useNNUE)
+ {
+ dp.piece[dp.dirty_num] = bpc;
+ dp.from[dp.dirty_num] = bsq;
+ dp.to[dp.dirty_num] = SQ_NONE;
+ dp.dirty_num++;
+ }
+
// Update board and piece lists
// In order to not have to store the values of both board and unpromotedBoard,
// demote promoted pieces, but keep promoted pawns as promoted,
PieceType castling_king_piece() const;
PieceType castling_rook_piece() const;
PieceType king_type() const;
+ PieceType nnue_king() const;
bool checking_permitted() const;
bool drop_checks() const;
bool must_capture() const;
return var->kingType;
}
+inline PieceType Position::nnue_king() const {
+ assert(var != nullptr);
+ return var->nnueKing;
+}
+
inline bool Position::checking_permitted() const {
assert(var != nullptr);
return var->checking;
// Max 3 pieces can change in one move. A promotion with capture moves
// both the pawn and the captured piece to SQ_NONE and the piece promoted
// to from SQ_NONE to the capture square.
- Piece piece[3];
+ Piece piece[12];
// From and to squares, which may be SQ_NONE
- Square from[3];
- Square to[3];
+ Square from[12];
+ Square to[12];
};
/// Score enum stores a middlegame and an endgame value in a single integer (enum).
// Derived properties
bool fastAttacks = true;
bool fastAttacks2 = true;
+ PieceType nnueKing = KING;
void add_piece(PieceType pt, char c, char c2 = ' ') {
pieceToChar[make_piece(WHITE, pt)] = toupper(c);
})
&& !cambodianMoves
&& !diagonalLines;
+ nnueKing = pieceTypes.find(KING) != pieceTypes.end() ? KING
+ : extinctionPieceTypes.find(COMMONER) != extinctionPieceTypes.end() ? COMMONER
+ : NO_PIECE_TYPE;
return this;
}
};