Determining Chess 960 Castling Rights?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Steve Maughan
Posts: 1250
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Determining Chess 960 Castling Rights?

Post by Steve Maughan »

I’m coding a new engine. I’m trying to get my head around chess960 castling. Suppose white has their king on A1 and a rook on G1. The FEN (Shredder style) says file “G” has castling rights. My question is, in this situation how does the engine determine if white can castle kingside or queenside?

Also, x-fen codes chess960 castling differently. Does any GUI serve up x-fen style FENs?

— Steve
http://www.chessprogramming.net - Maverick Chess Engine
mar
Posts: 2632
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Determining Chess 960 Castling Rights?

Post by mar »

in chess960, the king must always be placed between the rooks, so whether you use shredder style or X-fen doesn't really matter
so for shredder FEN, I'd simply check the castling letter relative to the king position to determine if it's kingside or queenside castling
other than that the castling always finishes just like in regular chess as you probably know and same rules apply

also chess960 has one extra tricky part to castling - you may not be allowed to castle due to opponent rook or queen on your backrank
besides the rook. this cannot happen in regular chess because the rooks initial position is always placed on the edge of the board
User avatar
Steve Maughan
Posts: 1250
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Determining Chess 960 Castling Rights?

Post by Steve Maughan »

Oh! I wasn’t aware the king must be between the rooks. That solves everything — thanks!

— Steve
http://www.chessprogramming.net - Maverick Chess Engine