StockFish Chess 960 castling FEN notation

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
tissatussa
Posts: 31
Joined: Sat Sep 24, 2016 4:13 am
Location: Netherlands
Full name: Roelof Berkepeis

StockFish Chess 960 castling FEN notation

Post by tissatussa »

can anyone tell me why StockFish at chess960 has castling rights like "KQ" in its FEN notation, not eg. "AG" ? Because, in a position where both rooks are on the same side of the king, it's unknown which rook has already moved and which rook is able to castle -- i'm not talking about any chess960 starting position, for the rooks must be on each side of the king. Some other chess engines do have "AG" ..
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: StockFish Chess 960 castling FEN notation

Post by hgm »

AFAIK GUIs always send 'Shredder FEN' (i.e. not KQ, but file IDs) to UCI engines in Chess960 mode. Engines that would not understand that will simply not work properly.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: StockFish Chess 960 castling FEN notation

Post by Evert »

UCI never requires the engine to output a FEN position, so any functionality it has to do so may not have received the same amount of testing as the rest of the code (certainly it would never cause problems if there are defects there). Chances are, it was only tested on regular chess, not on 960.

I think there are some well-defined rules on what "KQ" means in 960 (with respect to inner/outer rooks in case they are on the same side), but I don't remember what they are. Being explicit is simply easier anyway.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: StockFish Chess 960 castling FEN notation

Post by hgm »

In the X-FEN standard K and Q refer to the outer-most rook. But UCI does not use the X-FEN standard.
Modern Times
Posts: 3548
Joined: Thu Jun 07, 2012 11:02 pm

Re: StockFish Chess 960 castling FEN notation

Post by Modern Times »

Evert wrote: Chances are, it was only tested on regular chess, not on 960.
I've run over 30,000 chess960 games with various versions of Stockfish and it does play without any issues.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: StockFish Chess 960 castling FEN notation

Post by Evert »

Modern Times wrote:
Evert wrote: Chances are, it was only tested on regular chess, not on 960.
I've run over 30,000 chess960 games with various versions of Stockfish and it does play without any issues.
I may have misunderstood the OP's message, but I thought he was referring to FEN strings generated by Stockfish using KQ for castling rights, also in 960. That wouldn't be tested by playing games, since there is no situation where the GUI requests a FEN string from the engine.
Obviously problems with undertanding FEN strings would have been found.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: StockFish Chess 960 castling FEN notation

Post by hgm »

Why would Stockfish ever print FEN's?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: StockFish Chess 960 castling FEN notation

Post by Evert »

hgm wrote:Why would Stockfish ever print FEN's?
I don't know. I assumed it's some sort of test or debug feature.

There's just no other way I see "stockfish having KQ in FEN notation" make sense.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: StockFish Chess 960 castling FEN notation

Post by hgm »

I agree; you would not be able to see that if it was not printed. What it understands on input would be quite hard to deduce.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: StockFish Chess 960 castling FEN notation

Post by Joerg Oster »

tissatussa wrote:can anyone tell me why StockFish at chess960 has castling rights like "KQ" in its FEN notation, not eg. "AG" ? Because, in a position where both rooks are on the same side of the king, it's unknown which rook has already moved and which rook is able to castle -- i'm not talking about any chess960 starting position, for the rooks must be on each side of the king. Some other chess engines do have "AG" ..
This happens if you don't tell Stockfish to switch into Chess960 mode, of course!

Example:

Code: Select all

Stockfish 190117 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
uci
id name Stockfish 190117 64 POPCNT
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default 
option name Contempt type spin default 0 min -100 max 100
option name Threads type spin default 1 min 1 max 128
option name Hash type spin default 16 min 1 max 1048576
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 89 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 6 min 0 max 6
uciok
position fen nrnqkbbr/pppppppp/8/8/8/8/PPPPPPPP/NRNQKBBR w HBhb -
d

 +---+---+---+---+---+---+---+---+
 | n | r | n | q | k | b | b | r |
 +---+---+---+---+---+---+---+---+
 | p | p | p | p | p | p | p | p |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 | P | P | P | P | P | P | P | P |
 +---+---+---+---+---+---+---+---+
 | N | R | N | Q | K | B | B | R |
 +---+---+---+---+---+---+---+---+

Fen&#58; nrnqkbbr/pppppppp/8/8/8/8/PPPPPPPP/NRNQKBBR w KQkq - 0 1
Key&#58; 49811F8E3C74EEB8
Checkers&#58; 
And now with UCI_Chess960 true:

Code: Select all

Stockfish 190117 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
uci
id name Stockfish 190117 64 POPCNT
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default 
option name Contempt type spin default 0 min -100 max 100
option name Threads type spin default 1 min 1 max 128
option name Hash type spin default 16 min 1 max 1048576
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 89 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 6 min 0 max 6
uciok
setoption name UCI_Chess960 value true
position fen nrnqkbbr/pppppppp/8/8/8/8/PPPPPPPP/NRNQKBBR w HBhb -
d

 +---+---+---+---+---+---+---+---+
 | n | r | n | q | k | b | b | r |
 +---+---+---+---+---+---+---+---+
 | p | p | p | p | p | p | p | p |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 | P | P | P | P | P | P | P | P |
 +---+---+---+---+---+---+---+---+
 | N | R | N | Q | K | B | B | R |
 +---+---+---+---+---+---+---+---+

Fen&#58; nrnqkbbr/pppppppp/8/8/8/8/PPPPPPPP/NRNQKBBR w HBhb - 0 1
Key&#58; 49811F8E3C74EEB8
Checkers&#58; 
Jörg Oster