unclear 960 position regarding castling

Discussion of chess software programming and technical issues.

Moderator: Ras

ericlangedijk
Posts: 68
Joined: Thu Aug 08, 2013 5:13 pm

unclear 960 position regarding castling

Post by ericlangedijk »

[d]r2q3r/pp3pk1/2n1bbP1/3pN3/3P4/1BN4P/PP1Q1P2/R3R1K1 b Q -

In some datset I encounter this position indicating white can long castle. So must be chess960.
(there is also a pv included going: pv h8h6 e5g4 h6h3 e1e6 f7e6 g1a1 c6d4 b3d5 e6d5 g4f6).

Is there any consensus about which rook is the castling rook?
Both rooks could have moved. Both rooks could be the "castling" rook.

(I know this "Q" should actually be an "A" but anyway... what to do as a programmer)
User avatar
Tibono
Posts: 174
Joined: Sat Aug 01, 2015 6:16 pm
Location: France
Full name: Eric Bonneau

Re: unclear 960 position regarding castling

Post by Tibono »

If I understand correctly the rules, e1-Rook cannot be involved in a castling move. Because the King must be placed between both rooks in the starting position, hence either the King or the e1-Rook moved. If the King moved, any castling is ruled out. If e1-Rook moved, and King didn't, then a1-Rook is a candidate, assuming it didn't move so far. Castling also requires there is no piece in-between, hence the PV is including e1e6 Rook move.
Hope this helps...
mar
Posts: 2689
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: unclear 960 position regarding castling

Post by mar »

Tibono is right - white cannot possibly castle here, no matter if FRC or standard chess => the FEN has invalid castling rights
btw KQ is perfectly valid in X-FEN notation in Chess960, rook letters are used in S-FEN
Aleks Peshkov
Posts: 994
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: unclear 960 position regarding castling

Post by Aleks Peshkov »

https://en.wikipedia.org/wiki/X-FEN
the castling rights provided by this as default are related to the outermost rook of the affected side
ericlangedijk
Posts: 68
Joined: Thu Aug 08, 2013 5:13 pm

Re: unclear 960 position regarding castling

Post by ericlangedijk »

Use the outer most rooks. Ok! Thanks!

@Tibono: Not quite! With the given fen both rooks can be candidates for being the "castling" rook.
In the example it is possible (if we don't know the "outer rook" rule and assume the king was inbetween the rooks) that:
1) the king did not move.
2) the e1 rook is the castling rook and the a1 rook was originally on h1.
3) the a1 rook is the castling rook and the e1 rook was originally on h1
abulmo2
Posts: 493
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: unclear 960 position regarding castling

Post by abulmo2 »

ericlangedijk wrote: Tue May 12, 2026 4:09 pm Use the outer most rooks. Ok! Thanks!

@Tibono: Not quite! With the given fen both rooks can be candidates for being the "castling" rook.
In the example it is possible (if we don't know the "outer rook" rule and assume the king was inbetween the rooks) that:
1) the king did not move.
2) the e1 rook is the castling rook and the a1 rook was originally on h1.
3) the a1 rook is the castling rook and the e1 rook was originally on h1
I agree with you. The X-FEN notation is broken and cannot represent any chess 960 positions after having played some moves. Obviously, you cannot describe the case you describe in 2) with it. Fortunately, the S-FEN notation is the de facto standard used by UCI chess 960 engines & GUIs.
Richard Delorme
syzygy
Posts: 5977
Joined: Tue Feb 28, 2012 11:56 pm

Re: unclear 960 position regarding castling

Post by syzygy »

mar wrote: Tue May 12, 2026 3:16 pm Tibono is right - white cannot possibly castle here, no matter if FRC or standard chess => the FEN has invalid castling rights
btw KQ is perfectly valid in X-FEN notation in Chess960, rook letters are used in S-FEN
It seems to me the FEN has valid castling rights, it's just not legal to castle immediately (also because it's black turn to move ;-)).
Once the rook on e1 has moved away from rank 1, white can play o-o-o with king ending up on c1 and the rook on a1 ending up on d1.
syzygy
Posts: 5977
Joined: Tue Feb 28, 2012 11:56 pm

Re: unclear 960 position regarding castling

Post by syzygy »

ericlangedijk wrote: Tue May 12, 2026 1:01 pm [d]r2q3r/pp3pk1/2n1bbP1/3pN3/3P4/1BN4P/PP1Q1P2/R3R1K1 b Q -

In some datset I encounter this position indicating white can long castle. So must be chess960.
(there is also a pv included going: pv h8h6 e5g4 h6h3 e1e6 f7e6 g1a1 c6d4 b3d5 e6d5 g4f6).

Is there any consensus about which rook is the castling rook?
Both rooks could have moved. Both rooks could be the "castling" rook.

(I know this "Q" should actually be an "A" but anyway... what to do as a programmer)
I guess you're right that this FEN is simply ambiguous. It's clear that the king has not moved and that therefore the rook starting on h1 has moved, but we can't tell from the FEN if the rook moved from h1 to e1 (with the other rook starting on a1) or from h1 to a1 (with the other rook starting on e1).

edit: Aha, Aleks Peshkov is correct that the X-FEN standard handles this properly, but I think a bit more has to be cited:
The new and crucial point of the arrangement is that the castling rights provided by this as default are related to the outermost rook of the affected side. If instead an inner rook is associated with that right, the traditional castling tag will be replaced by the file letter of the involved rook, using upper case for White.
So indeed Q refers to the outermost rook. If instead white can long-castle with the rook on e1, then it would have said E instead of Q.

So the X-FEN is both unambiguous and standard compliant (assuming Wikipedia correctly reflects the standard).
mar
Posts: 2689
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: unclear 960 position regarding castling

Post by mar »

syzygy wrote: Wed May 13, 2026 12:51 am It seems to me the FEN has valid castling rights, it's just not legal to castle immediately (also because it's black turn to move ;-)).
Once the rook on e1 has moved away from rank 1, white can play o-o-o with king ending up on c1 and the rook on a1 ending up on d1.
sure, if you take the X-FEN parsing rules literally, you'll get an S-FEN with A.
this is probably a standard chess position with wrong castling rights, otherwise I'd like to see that rook manoeuvre from h1 :)