Forcing and undoing castling