Skip to content

was_into_check behavior on multiple kings #1169

@winapiadmin

Description

@winapiadmin

was_into_check (L1995-L1997)

    def was_into_check(self) -> bool:
        king = self.king(not self.turn)
        return king is not None and self.is_attacked_by(self.turn, king)

Here it only picks one king.... but if the position loaded has multiple kings, it only return the bool of one king which depends on FEN parsing order, that means - a flipped position can bring different king of the corresponding side to move.

While it isn't too much - this is kind of UB for pseudo-legal FENs, and it affects Board.is_valid, Board.status and possibly its variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions