@@ -192,7 +192,6 @@ class Position {
192192 std::array<Bitboard, PIECE_TYPE_NB> byTypeBB;
193193 std::array<Bitboard, COLOR_NB> byColorBB;
194194
195- Square kingSquare[COLOR_NB];
196195 int pieceCount[PIECE_NB];
197196 uint64_t midEncoding[COLOR_NB];
198197 StateInfo* st;
@@ -248,7 +247,10 @@ inline int Position::count() const {
248247 return count<Pt>(WHITE) + count<Pt>(BLACK);
249248}
250249
251- inline Square Position::king_square (Color c) const { return kingSquare[c]; }
250+ inline Square Position::king_square (Color c) const {
251+ return c == WHITE ? lsb (uint64_t (pieces (KING)))
252+ : Square (64 + lsb (uint64_t (pieces (KING) >> 64 )));
253+ }
252254
253255inline uint64_t Position::mid_encoding (Color c) const { return midEncoding[c]; }
254256
@@ -351,8 +353,6 @@ inline void Position::move_piece(Square from, Square to, DirtyThreats* const dts
351353 byColorBB[color_of (pc)] ^= fromTo;
352354 board[from] = NO_PIECE;
353355 board[to] = pc;
354- if (type_of (pc) == KING)
355- kingSquare[color_of (pc)] = to;
356356 midEncoding[color_of (pc)] -= Eval::NNUE::Features::HalfKAv2_hm::MidMirrorEncoding[pc][from];
357357 midEncoding[color_of (pc)] += Eval::NNUE::Features::HalfKAv2_hm::MidMirrorEncoding[pc][to];
358358
@@ -369,8 +369,6 @@ inline void Position::swap_piece(Square s, Piece pc, DirtyThreats* const dts) {
369369 update_piece_threats<false , false >(old, s, dts);
370370
371371 put_piece (pc, s);
372- if (type_of (pc) == KING)
373- kingSquare[color_of (pc)] = s;
374372
375373 if (dts)
376374 update_piece_threats<true , false >(pc, s, dts);
0 commit comments