lichess.org
Donate

Lichess castling bug?

Was studying a position that IM Andras got in one of his games and noticed Stockfish recommending an illegal move, and Lichess allowing that illegal move to be played. Check it out in this study:

@xedrac I think it's a Fischer random chess game. The move (long castling) is perfectly legal.
To be precise, it's an asymmetric version of Fischer random: try playing 1...O-O-O 2. Rf3 Rg8 3. O-O-O.

If you don't want that, you have to uncheck the castling rights when setting up the position.
I don't know how you initially set up the position, but, as Vempele already said, the castling rights have not been defined properly.

You can see that immediately when you look at the FEN for your position:
1r2kr2/1bpqbp2/p1n3p1/1p1NP2p/2p1NQ1P/4P1P1/PP4B1/R4RK1 b Qkq - 0 1

The 3rd field of the string ("Qkq") tells the engine, that white can still castle queenside and black can castle on both sides.

If you want to tell the engine that no castling is possible in the position, then you have to use the following FEN:
1r2kr2/1bpqbp2/p1n3p1/1p1NP2p/2p1NQ1P/4P1P1/PP4B1/R4RK1 b - - 0 1
It sounds like I just set up the board incorrectly. Is normal chess not the default assumption when editing a board? I didn't explicitely select a variant, such as Fischer Random...
Step 1: Go to board editor.
Step 2: Examine options.
Step 3: Try again.
So actually your study is not a variant study, it IS standard chess.

The thing is, that the presence or absence of castling rights (just as possible en passant captures, halfmoves since the last capture or pawn advance, etc) are part of the description of a standard chess position. That's why this information is encoded in the FEN, it has nothing to do with Chess960.

And if you set up a *custom position* in the board editor, lichess does not take the freedom to assume which series of legal moves from the standard starting position could have created that particular end position (and therefore whether castling is still possible or not). In a lot of cases this will be ambiguous anyway, so you have to know it yourself.

It even seems that the board editor only defaults to "castling enabled" when you start from the standard starting position. When you start with a clean board, castling rights are off by default. I think that is a very reasonable behaviour.
@flaeschle you are right about the FEN notation missing the info about castling rights; nonetheless, under the assumption that we are dealing with standard chess, the position should not allow for castling no matter what the FEN says, as the rook is not in its starting position... A move like the one reported in this post should only be possible in a Fischer Random game. I believe that leaving the option for castling active in such a position make the engine "switch" to Fischer Random mode, allowing the players to castle even if the pieces are not where they are supposed to be in a standard game.
@picchiolu I'm not an engine developer, but my understanding is, that chess engines always work with the generalized castling rules, they do not have different modes for Chess960 or standard chess.

And of course you are right, for us humans it is immediately obvious that you should not be able to castle here if we are talking about standard chess. So I can absolutely understand the confusion of @xedrac, but I still think this is not a bug. The only thing the engine sees, is the position as defined by the FEN.

Unless lichess implements some additional logic in the study chapters or board editor (at the moment the board editor is agnostic about variants), I would say, everything works correctly.
@flaeschle Stockfish does have an option to enable/disable Chess960, since the representation of castling moves depends on that option in the UCI protocol. However, it could be that lichess enables Chess960 by default when playing "from position".

This topic has been archived and can no longer be replied to.