Skip to content

FromPosition matches with FRC castling rights are accepted and correctly handled by the Lichess GUI, but cause issues for lichess-bot #1146

@Naphthalin

Description

@Naphthalin

Describe the bug
lichess-bot bots can't handle FRC FromPosition games, will receive wrong castling rights from the server, and error out after the opponent castles "illegally". https://lichess.org/rQA6AjkX as an example.

To Reproduce
Steps to reproduce the behavior:

  1. Challenge a lichess-bot who accepts arbitrary FromPosition challenges to a position with FRC castling rights included, like rbqnkrbn/pppppppp/8/8/8/8/PPPPPPPP/RBQ1KRBN w AFaf - 0 1
  2. Castle by capturing your own rook
  3. Bot errors out because it can't set up the correct position and will time out.

Expected behavior
https://github.com/lichess-bot-devs/lichess-bot/blob/master/lib/lichess_bot.py#L832-L835
This should also set the mode to chess960=True if it's a "From Position" but with FRC castling rights. However, a quick test shows that game.initial_fen seems to have standard castling rights, so this might require some additional logic.

Logs
Throws a uci move when handling the FRC castling:

line 3147, in parse_uci
                                 raise IllegalMoveError(f"illegal uci: {uci!r} in {self.fen()}")
                             chess.IllegalMoveError: illegal uci: 'e8f8' in
                             rbqnkr1n/ppppp1pp/4b3/5p2/2P2P2/2Q5/PP1PP1PP/RB2KRBN b Qq - 2 3
[10/10/25 09:36:18] ERROR    Ignoring illegal move e8f8 on board
started from rbqnkrb

Desktop (please complete the following information):

  • OS: [e.g. Windows]
  • Python Version: [e.g. 3.11]
  • Terminal: [e.g. Command Line, PowerShell]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions