FRC / Chess960 -- Some Lessons I Learned

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
elcabesa
Posts: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by elcabesa » Sun Jun 23, 2019 4:50 pm

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: 23772
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by hgm » Sun Jun 23, 2019 5:44 pm

D Sceviour wrote:
Sun Jun 23, 2019 4: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: 23772
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by hgm » Sun Jun 23, 2019 5:58 pm

AndrewGrant wrote:
Sun Jun 23, 2019 12:30 pm
I 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: 463
Joined: Mon Jul 20, 2015 3:06 pm
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by D Sceviour » Sun Jun 23, 2019 6:23 pm

hgm wrote:
Sun Jun 23, 2019 5:44 pm
D Sceviour wrote:
Sun Jun 23, 2019 4: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: 23772
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by hgm » Sun Jun 23, 2019 6:31 pm

D Sceviour wrote:
Sun Jun 23, 2019 6:23 pm
hgm wrote:
Sun Jun 23, 2019 5:44 pm
D Sceviour wrote:
Sun Jun 23, 2019 4: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: 493
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by AndrewGrant » Sun Jun 23, 2019 8:55 pm

hgm wrote:
Sun Jun 23, 2019 5: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.

Modern Times
Posts: 2417
Joined: Thu Jun 07, 2012 9:02 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by Modern Times » Tue Jun 25, 2019 7:40 pm

AndrewGrant wrote:
Sat Jun 22, 2019 2:34 pm
involves. 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 ?
.

Opinions expressed here are my own, and not necessarily those of the CCRL Group.

AndrewGrant
Posts: 493
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: FRC / Chess960 -- Some Lessons I Learned

Post by AndrewGrant » Wed Jun 26, 2019 10:56 am

Modern Times wrote:
Tue Jun 25, 2019 7:40 pm
AndrewGrant wrote:
Sat Jun 22, 2019 2:34 pm
involves. 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".

Modern Times
Posts: 2417
Joined: Thu Jun 07, 2012 9:02 pm

Re: FRC / Chess960 -- Some Lessons I Learned

Post by Modern Times » Wed Jun 26, 2019 5:41 pm

Thanks, I'll wait for 11.50 :)
.

Opinions expressed here are my own, and not necessarily those of the CCRL Group.

MikeB
Posts: 3537
Joined: Thu Mar 09, 2006 5:34 am
Location: Pen Argyl, Pennsylvania

Re: FRC / Chess960 -- Some Lessons I Learned

Post by MikeB » Thu Jul 04, 2019 4:08 am

D Sceviour wrote:
Sun Jun 23, 2019 4: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:


*

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



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.

Post Reply