FRC / Chess960 -- Some Lessons I Learned

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by elcabesa »

I don't think any castling is allowed since king after castling will be in check or the final square is already occupied
User avatar
hgm
Posts: 27788
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 »

D Sceviour wrote: Sun Jun 23, 2019 6:37 pm[d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
Castling is never allowed when you have no castling rights!
User avatar
hgm
Posts: 27788
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 »

AndrewGrant wrote: Sun Jun 23, 2019 2:30 pmI have the following scheme, which seems to be the fastest I can come up with. Ease of move type detection is worth speed, and its about more then just figuring out how to apply the move, you have to consider all the places in evaluation, movepicking, searching, where move type is needed. Promotion type conversation is just a bitshift of the move as well. To/From are encoded in the lower 12 bits, like everyone else.
I doubt very much whether this is the fastest possible, though. But that depends a bit on how often you test overall and for what. If there are a hundred different places where you test for castling versus one where you test for promotion, then what you use could have merits. (But likely it would mean the codes sucks in other ways...)

Castlings, promotions, e.p. capture, double pushes together are still pretty rare. (Double pushes probably least so.) By general considerations that suggests it would be best to use the simplest possible filter to rule them out (like doing a test-and-branch on a single bit). How you then continue if you are dealing with one of those already hardly matters, as this code would almost never be executed. If you test every move separately for being a castling or being a promotion, you need two test-and-branches in the common case, which is almost certainly twice as much overhead on behalf of the special moves.

You mention a 2 Elo weakening, which is really ridiculously much. It corresponds to a 2% slowdown, just because of the way you handle a move that makes up at best ~5% of the number of moves, but during the final 2/3 of the game is usually not possible at all, and in fact will hardly ever be possible after you left the opening book. I would be surpried if castling is possible for more than 5 moves per game on average. I would think that if there would be any measurable Elo decrease something should be very, very wrong.
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by D Sceviour »

hgm wrote: Sun Jun 23, 2019 7:44 pm
D Sceviour wrote: Sun Jun 23, 2019 6:37 pm [d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
Castling is never allowed when you have no castling rights!
Not sure what you mean. Do you mean no "KQkq" included in the fen? The FRC rules require that the king has to sit between two rooks. Perhaps the answer is no, because no pieces can lie between the rook and the king. The rook on C1 blocks the queen side castle.

For example of a known legal position in FRC, queen side castle is allowed:

[d]rk2r3/8/8/8/8/8/3PP3/RK2R3 w - - 0 1
User avatar
hgm
Posts: 27788
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 »

D Sceviour wrote: Sun Jun 23, 2019 8:23 pm
hgm wrote: Sun Jun 23, 2019 7:44 pm
D Sceviour wrote: Sun Jun 23, 2019 6:37 pm [d]5rkr/8/8/8/8/8/8/RKR5 w - - 0 1
Castling is never allowed when you have no castling rights!
Not sure what you mean. Do you mean no "KQkq" included in the fen?
At least. '-' in the castling rights field means no castlings are possible anymore.

But it is more than that: KQkq would not be a valid castling rights in this position, as Chess960 positions are mirror symmetric. Your position isn't, so either the white or black King must have moved, and possibly both. And your question is ambiguous anyway, because the answer would be different for the whte and for black, if this happened to be the color that still had Q or q rights.
AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: FRC / Chess960 -- Some Lessons I Learned

Post by AndrewGrant »

hgm wrote: Sun Jun 23, 2019 7:58 pm You mention a 2 Elo weakening, which is really ridiculously much. It corresponds to a 2% slowdown, just because of the way you handle a move that makes up at best ~5% of the number of moves, but during the final 2/3 of the game is usually not possible at all, and in fact will hardly ever be possible after you left the opening book. I would be surpried if castling is possible for more than 5 moves per game on average. I would think that if there would be any measurable Elo decrease something should be very, very wrong.
The final test for non-regression ended as follows

Code: Select all

ELO   | 0.09 +- 2.66 (95%)
SPRT  | 10.0+0.1s Threads=1 Hash=8MB
LLR   | 2.98 (-2.94, 2.94) [-5.00, 0.00]
Games | N: 26440 W: 5348 L: 5341 D: 15751
So in the end, no slowdown, likely for the reasons you stated.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Modern Times
Posts: 3546
Joined: Thu Jun 07, 2012 11:02 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by Modern Times »

AndrewGrant wrote: Sat Jun 22, 2019 4:34 pminvolves. I'm always scared to push things like this, since something may break no matter how careful I am, but I plan to push this before Version 11.50.
Hi Andrew,

So if I read this correctly there will be two versions in the near future - basically 11.25 with FRC support, and then 11.50 later ?
AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: FRC / Chess960 -- Some Lessons I Learned

Post by AndrewGrant »

Modern Times wrote: Tue Jun 25, 2019 9:40 pm
AndrewGrant wrote: Sat Jun 22, 2019 4:34 pminvolves. I'm always scared to push things like this, since something may break no matter how careful I am, but I plan to push this before Version 11.50.
Hi Andrew,

So if I read this correctly there will be two versions in the near future - basically 11.25 with FRC support, and then 11.50 later ?
So I have pushed support for FRC with version 11.46, which is available on Github. So, as of now, if you want an Ethereal with FRC support it exists. I tend to make the "Official Release" posts every 25 or so patches. V11.50 is the next planned release, which will be within a week or two.

I am in the process of doing large code cleanups and standardization. 11.50 is going to be released as "Here is FRC, and also I've cleaned a lot of things up so that people can benefit from Ethereal more easily".
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Modern Times
Posts: 3546
Joined: Thu Jun 07, 2012 11:02 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by Modern Times »

Thanks, I'll wait for 11.50 :)
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 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.
Image