FRC / Chess960 -- Some Lessons I Learned

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Uri Blass
Posts: 10268
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: FRC / Chess960 -- Some Lessons I Learned

Post by Uri Blass »

I do not see the second game
I post only the second game.

I think long castling is allowed for white only if white move Rook c1 first or to be more accurate only if c1 d1 are empty
Edit:or to be more accurate the opponent also cannot threat a square between the king and the destination square when the player castle.

[pgn][Event " "] [Site "somewhere"] [Date "2019.07.03"] [Round "-"] [White "me"] [Black "you"] [Result "*"] [TimeControl "15+1"] [Variant "fischerandom"] [FEN "rkrnnqbb/pppppppp/8/8/8/8/PPPPPPPP/RKRNNQBB w CAca - 0 1"] [SetUp "1"] 1. Nc3 f5 {+52.92/21 +13} 2. Nd3 d6 {+53.16/19 +13} 3. Re1 g6 {+53.78/19 +13} 4. O-O-O Bxc3 {+55.12/16 +13}[/pgn]
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: FRC / Chess960 -- Some Lessons I Learned

Post by hgm »

MikeB wrote: Thu Jul 04, 2019 6:08 am
D Sceviour wrote: Sun Jun 23, 2019 6:37 pm What would be the final castling positions for this initial FRC position? Is queen side castling allowed?


[d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
In Chess960, after castling, the king and rook's final positions are exactly the same as they would be in standard chess. So you need to clear the pieces that are in the way. The standard convention in castling in a Chess960 GUI, you placed the king ON the rook you are castling with. See the two fake game snippets below:

[pgn][Event " "] [Site "somewhere"] [Date "2019.07.03"] [Round "-"] [White "me"] [Black "you"] [Result "*"] [TimeControl "15+1"] [Variant "fischerandom"] [FEN "rkrnnqbb/pppppppp/8/8/8/8/PPPPPPPP/RKRNNQBB w CAca - 0 1"] [SetUp "1"] 1. Nc3 f5 {+52.18/22 +12} 2. Nd3 d6 {+51.97/19 +12} 3. e3 g6 {+55.45/18 +13} 4. Qe2 c5 {+58.12/19 +11} 5. f3 Nc6 {+59.75/17 +11} 6. Bf2 c4 {+63.14/17 +11} 7. Nf4 Nc7 {+64.28/15 +11} 8. O-O e5 {+67.57/17 +12} * [Event " "] [Site "somewhere"] [Date "2019.07.03"] [Round "-"] [White "me"] [Black "you"] [Result "*"] [TimeControl "15+1"] [Variant "fischerandom"] [FEN "rkrnnqbb/pppppppp/8/8/8/8/PPPPPPPP/RKRNNQBB w CAca - 0 1"] [SetUp "1"] 1. Nc3 f5 {+52.92/21 +13} 2. Nd3 d6 {+53.16/19 +13} 3. Re1 g6 {+53.78/19 +13} 4. O-O-O Bxc3 {+55.12/16 +13}[/pgn]
*

So the castled positions will ALWAYS look like this - white is queenside, black shows kingside

[d]5rk1/8/8/8/8/8/8/2KR4 w - - 0 1

It's amazing how you got picked on for not asking the question "properly" , but no one really answered your question even though it doesn't take a rocket scientist to understand what you were asking for. Instead , they wasted your time, my time and their time to tell you what was wrong with your question. - instead of just answering the obvious question you were asking - how does one castle in Chess960.
Doesn't seem you answer the question, though. He asked for 'Queen-side castling', and you show him King-side, and for the placement of the white pieces only. He could have been asking for black. And the Rooks and Kings are not in the position he gives. Perhaps it is rocket science, but you assume he knows zilch and asks for what everyone knows. His question might very well have been about which squares must be empty or not attacked, if he is a bit smarter than you give him credit for...
LocutusOfPenguin
Posts: 34
Joined: Thu Sep 28, 2017 6:52 pm
Location: Karlsruhe, Germany
Full name: Jürgen Précour

Re: FRC / Chess960 -- Some Lessons I Learned

Post by LocutusOfPenguin »

elcabesa wrote: Sun Jun 23, 2019 6:17 pm thank you for your EPD file,

I'm about to release a version of Vajolet with FRC and I thought that my movegen code was correct, but I was wrong :(
now a small castle bug has been solved
Hi,

may i ask for the current status of 2.8 or esp for FRC?
The last release (github) is 2.7 but yr releaseNote.txt saying 2.8 since 4m.

If it stable and FRC implemented, i would put it in the first top 8 places of picochess (advantage: allows to choose engine by Queen) .

Jürgen
Create a dedicated chess computer based on tiny ARM computers with the DGT e-board on picochess.com
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by elcabesa »

I plan to release it shortly
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: FRC / Chess960 -- Some Lessons I Learned

Post by MikeB »

LocutusOfPenguin wrote: Thu Oct 24, 2019 4:47 pm
elcabesa wrote: Sun Jun 23, 2019 6:17 pm thank you for your EPD file,

I'm about to release a version of Vajolet with FRC and I thought that my movegen code was correct, but I was wrong :(
now a small castle bug has been solved
Hi,

may i ask for the current status of 2.8 or esp for FRC?
The last release (github) is 2.7 but yr releaseNote.txt saying 2.8 since 4m.

If it stable and FRC implemented, i would put it in the first top 8 places of picochess (advantage: allows to choose engine by Queen) .

Jürgen
Good to see you posting about picochess updates!
Image
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by D Sceviour »

D Sceviour wrote: Sun Jun 23, 2019 6:37 pm What would be the final castling positions for this initial FRC position? Is queen side castling allowed?

[d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
Q-side castling seems illegal in this position based on the castling rules for FRC:

All the squares between the king's initial and final squares (including the final square), and all the squares between the castling rook's initial and final squares (including the final square), must be vacant except for the king and castling rook.

Looking at the first rank initial positions for king and rooks, there are four illegal positions for castling. This table may be of some help in visualizing the possibilities.

Code: Select all

INITIAL POSITION    Q-SIDE CASTLE      K-SIDE CASTLE
R K . . . . . R     . . K R . . . R    R . . . . R K .
R . K . . . . R     . . K R . . . R    R . . . . R K .
R . . K . . . R     . . K R . . . R    R . . . . R K .
R . . . K . . R     . . K R . . . R    R . . . . R K .
R . . . . K . R     . . K R . . . R    R . . . . R K .
R . . . . . K R     . . K R . . . R    R . . . . R K .

R K . . . . R .     . . K R . . R .    R . . . . R K .
R . K . . . R .     . . K R . . R .    R . . . . R K .
R . . K . . R .     . . K R . . R .    R . . . . R K .
R . . . K . R .     . . K R . . R .    R . . . . R K .
R . . . . K R .     . . K R . . R .    R . . . . R K .

R K . . . R . .     . . K R . R . .    R . . . . R K .
R . K . . R . .     . . K R . R . .    R . . . . R K .
R . . K . R . .     . . K R . R . .    R . . . . R K .
R . . . K R . .     . . K R . R . .    R . . . . R K .

R K . . R . . .     . . K R R . . .    R . . . . R K .
R . K . R . . .     . . K R R . . .    R . . . . R K .
R . . K R . . .     . . K R R . . .    R . . . . R K .

R K . R . . . .       ILLEGAL          R . . . . R K .
R . K R . . . .       ILLEGAL          R . . . . R K .

R K R . . . . .       ILLEGAL          R . . . . R K .

. R K . . . . R     . . K R . . . R    . R . . . R K .
. R . K . . . R     . . K R . . . R    . R . . . R K .
. R . . K . . R     . . K R . . . R    . R . . . R K .
. R . . . K . R     . . K R . . . R    . R . . . R K .
. R . . . . K R     . . K R . . . R    . R . . . R K .

. . R K . . . R     . . K R . . . R    . . R . . R K .
. . R . K . . R     . . K R . . . R    . . R . . R K .
. . R . . K . R     . . K R . . . R    . . R . . R K .
. . R . . . K R     . . K R . . . R    . . R . . R K .

. . . R K . . R     . . K R . . . R    . . . R . R K .
. . . R . K . R     . . K R . . . R    . . . R . R K .
. . . R . . K R     . . K R . . . R    . . . R . R K .

. . . . R K . R     . . K R . . . R    . . . . R R K .
. . . . R . K R     . . K R . . . R    . . . . R R K .

. . . . . R K R     . . K R . . . R      ILLEGAL
Shuffle chess rules seem easier to deal with. Fischer's point was to get people out of the book. Denying castling for non-standard King-Rook arrangements in shuffle chess does this adequately, although Fischer does seem to have spent some time defining the special castling rules.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: FRC / Chess960 -- Some Lessons I Learned

Post by MikeB »

D Sceviour wrote: Sun Oct 27, 2019 1:12 pm
D Sceviour wrote: Sun Jun 23, 2019 6:37 pm What would be the final castling positions for this initial FRC position? Is queen side castling allowed?

[d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
Q-side castling seems illegal in this position based on the castling rules for FRC:

All the squares between the king's initial and final squares (including the final square), and all the squares between the castling rook's initial and final squares (including the final square), must be vacant except for the king and castling rook.

Looking at the first rank initial positions for king and rooks, there are four illegal positions for castling. This table may be of some help in visualizing the possibilities.

Code: Select all

INITIAL POSITION    Q-SIDE CASTLE      K-SIDE CASTLE
R K . . . . . R     . . K R . . . R    R . . . . R K .
R . K . . . . R     . . K R . . . R    R . . . . R K .
R . . K . . . R     . . K R . . . R    R . . . . R K .
R . . . K . . R     . . K R . . . R    R . . . . R K .
R . . . . K . R     . . K R . . . R    R . . . . R K .
R . . . . . K R     . . K R . . . R    R . . . . R K .

R K . . . . R .     . . K R . . R .    R . . . . R K .
R . K . . . R .     . . K R . . R .    R . . . . R K .
R . . K . . R .     . . K R . . R .    R . . . . R K .
R . . . K . R .     . . K R . . R .    R . . . . R K .
R . . . . K R .     . . K R . . R .    R . . . . R K .

R K . . . R . .     . . K R . R . .    R . . . . R K .
R . K . . R . .     . . K R . R . .    R . . . . R K .
R . . K . R . .     . . K R . R . .    R . . . . R K .
R . . . K R . .     . . K R . R . .    R . . . . R K .

R K . . R . . .     . . K R R . . .    R . . . . R K .
R . K . R . . .     . . K R R . . .    R . . . . R K .
R . . K R . . .     . . K R R . . .    R . . . . R K .

R K . R . . . .       ILLEGAL          R . . . . R K .
R . K R . . . .       ILLEGAL          R . . . . R K .

R K R . . . . .       ILLEGAL          R . . . . R K .

. R K . . . . R     . . K R . . . R    . R . . . R K .
. R . K . . . R     . . K R . . . R    . R . . . R K .
. R . . K . . R     . . K R . . . R    . R . . . R K .
. R . . . K . R     . . K R . . . R    . R . . . R K .
. R . . . . K R     . . K R . . . R    . R . . . R K .

. . R K . . . R     . . K R . . . R    . . R . . R K .
. . R . K . . R     . . K R . . . R    . . R . . R K .
. . R . . K . R     . . K R . . . R    . . R . . R K .
. . R . . . K R     . . K R . . . R    . . R . . R K .

. . . R K . . R     . . K R . . . R    . . . R . R K .
. . . R . K . R     . . K R . . . R    . . . R . R K .
. . . R . . K R     . . K R . . . R    . . . R . R K .

. . . . R K . R     . . K R . . . R    . . . . R R K .
. . . . R . K R     . . K R . . . R    . . . . R R K .

. . . . . R K R     . . K R . . . R      ILLEGAL
Shuffle chess rules seem easier to deal with. Fischer's point was to get people out of the book. Denying castling for non-standard King-Rook arrangements in shuffle chess does this adequately, although Fischer does seem to have spent some time defining the special castling rules.
This position is not a legal opening in Chess 960 (FRC). The opening's are always mirrored

Position # 959 is this :

[d]rkrnnqbb/pppppppp/8/8/8/8/PPPPPPPP/RKRNNQBB w CAca - 0 1

You have to remember that in Chess 960 , the placement of the K and R after castling is the same as normal chess,


[pgn][Date "2019.10.27"] [Round "-"] [White "*"] [Black "*"] [Result "*"] [TimeControl "5+0"] [Variant "fischerandom"] [FEN "rkrnnqbb/pppppppp/8/8/8/8/PPPPPPPP/RKRNNQBB w CAca - 0 1"] [SetUp "1"] 1. c4 f5 {+49.84/17 +4} 2. d3 g5 {+55.00/13 +4} 3. Ne3 f4 {+61.94/14 +4} 4. Rc2 fxe3 {+80.28/11 +4} 5. O-O-O Nc6 {+89.04/13 +4}[/pgn]*
*

so after white queenside castles the position will look this

[d]rkr1nqbb/ppppp2p/2n5/6p1/2P5/3Pp3/PPR1PPPP/2KRNQBB w ca - 2 6

So this rule "All the squares between the king's initial and final squares (including the final square), and all the squares between the castling rook's initial and final squares (including the final square), must be vacant except for the king and castling rook." is followed in the above example
Image
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by D Sceviour »

MikeB wrote: Mon Oct 28, 2019 4:54 am This position is not a legal opening in Chess 960 (FRC). The opening's are always mirrored
No, the position is legal but castling is not legal. It might have made it easier to visualize the q-side castle with the FRC nomneclature for castling: AC. Another point is that the castling nomenclature AC could\should not be there if castling is illegal even if the white kings and rooks have not moved from the initial position.

[d]5rkr/8/8/8/8/8/8/RKR5 w AC - 0 1

or maybe this fen,

[d]6k1/8/8/8/8/8/8/RKR5 w AC - 0 1
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: FRC / Chess960 -- Some Lessons I Learned

Post by MikeB »

D Sceviour wrote: Mon Oct 28, 2019 2:23 pm
MikeB wrote: Mon Oct 28, 2019 4:54 am This position is not a legal opening in Chess 960 (FRC). The opening's are always mirrored
No, the position is legal but castling is not legal. It might have made it easier to visualize the q-side castle with the FRC nomneclature for castling: AC. Another point is that the castling nomenclature AC could\should not be there if castling is illegal even if the white kings and rooks have not moved from the initial position.

[d]5rkr/8/8/8/8/8/8/RKR5 w AC - 0 1

or maybe this fen,

[d]6k1/8/8/8/8/8/8/RKR5 w AC - 0 1
I'm sorry, I see now I do not understand your castling questions, nor do I care to at this point, so I must withdraw from the conversation.
Image
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by D Sceviour »

I decided to try FRC in Schooner. The castle move is still treated as a king move from-to, so KxR is not used as move code. The castle direction is determined by a 4-bit flag tacked on to the end of the move stored. Considerable changes had to made for the castling flags in 10 different files.
AndrewGrant wrote: Sat Jun 22, 2019 4:34 pm Currently the elo loss is around 1 to 2, played at 10+.1s, which I think is quite respectable for the overhead that FRC involves.
There is a 25 elo loss for normal chess at the moment, so a release version will not be coming soon. There should be no loss hopefully when done. There may be a number of problems in move evaluation and scoring still to find. If the king move fromsq = tosq, then the scoring evaluations do not change for castling. If there is KxR because the rook occupies the king tosq, then one has to be careful not to deduct the value of rook if there is a material scoring during the make move process. Also, the new move flags might be interfering with move evaluations and move sorting.
AndrewGrant wrote: Sat Jun 22, 2019 4:34 pm "One setback to my method is that additional getlsb() & getmsb() calls are needed to locate the rook you are castling to."
That is not a problem at the root. It would only be a problem if this is done for every node and every move list generated. A variable:

int white_root_rook_sq_left, etc.

can be calculated at the root and used to locate the rooks for castling.

Considerable re-write of code had to be done for testing castling legality. Two new bitboard variables are calculated at the root. First is a:

U64 castle_occ_WL, castle_occ_WR, castle_occ_BL, castle_occ_BR;

This is a bitboard containing all the squares that the board must be empty of excluding the king and the rook since the king can occupy the tosq. The in-between rook travelling squares are included. Here, the king side castle can also cross over the king side rook, so the rook occupancy has to be ignored:

[d]r1k1r3/ppp2ppp/8/4p3/4P3/8/PPP2PPP/R1K1R3 w AEae - 0 1

The second is a U64 castle_line_WR bitboard containing all the squares between the king fromsq and the king tosq, including the king fromsq and the king tosq. This is used to determine what squares have to be free from checks before castling. There is no requirement that the rook traveling squares have to be free from checks.

All the perft tests passed for regular chess. Preliminary FRC tests have shown a few of the same results published by Andrew, but not all have been tested and confirmed yet.