Program didn’t realize that capturing a rook with castling-potential with a pawn (therefore promoting) prevented future castling with said rook. This is not rectified.