Fix castling initialization for placement chess
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 12 Mar 2021 18:20:41 +0000 (19:20 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 12 Mar 2021 18:20:41 +0000 (19:20 +0100)
Refactoring of 960 castling broke placement chess castling.
Add initialization of king position to prevent undefined behavior.

src/position.cpp

index d9deef6..3622b30 100644 (file)
@@ -1498,6 +1498,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
       {
           if (type_of(pc) == castling_king_piece() && file_of(to) == castling_king_file())
           {
+              st->castlingKingSquare[us] = to;
               Bitboard castling_rooks =  pieces(us, castling_rook_piece())
                                        & rank_bb(castling_rank(us))
                                        & (file_bb(FILE_A) | file_bb(max_file()));