Can Sjaak II do British Chess (aka Caissa Brittania)?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by hgm »

The unusual aspect of British Chess is that the royal piece is a Queen. The problem that it is next to impossible to checkmate a piece this strong is solved by the extra rule that these Royal Queens cannot move through check (except for capturing each other). Can such a rule be specified in Sjaak II?

Initially I thought I could trivially implement this in Fairy-Max, making use of the fact that this searches moves in move-generation order; the first illegal move with a royal piece can then simply terminate the ray scan (e.g. by faking that the to-square was occupied). In the 'pre-iteration' it runs through all moves to find the MVV without searching any reply, so no moves can be illegal there, and it would always find a QxQ if there is one.

Problem, however, is that this does not work in QS, because the non-captures that move into check will not be searched there, so that they are not recognized as illegal, and the ray scan will go on beyond them to generate captures that in reality should not exist. This will revive the old problem for not having QS, that it will try to make the most profitable illegal capture with its Queen at the horizon, not realizing that it will give away its Queen that way through a kind of e.p. recapture.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

hgm wrote:The unusual aspect of British Chess is that the royal piece is a Queen. The problem that it is next to impossible to checkmate a piece this strong is solved by the extra rule that these Royal Queens cannot move through check (except for capturing each other). Can such a rule be specified in Sjaak II?
No.
But it could be done by adding an extra rule that triggers a test for the intersection of the ray through the from/to squares and the enemy attacks. If done properly it might not even be horrendously slow.

Since I'm in the process of considering some other new rules as well (for traditional Sittuyin promotion rules) I'd be happy to include this one too.
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by hgm »

That would be great. I really like this idea of 'defusing' an in itself powerful royal slider by the restriction of not being allowed to move through check. It seems to lead to quite playable end-games. E.g. QRQ would be a win, but QBQ and QNQ would be draws, while two minors would again have mating potential. The point is that the strong side also has this powerful royal, which can confine the bare Queen all by itself, and easily drive it towards a corner by zugzwang.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

hgm wrote:That would be great. I really like this idea of 'defusing' an in itself powerful royal slider by the restriction of not being allowed to move through check. It seems to lead to quite playable end-games. E.g. QRQ would be a win, but QBQ and QNQ would be draws, while two minors would again have mating potential. The point is that the strong side also has this powerful royal, which can confine the bare Queen all by itself, and easily drive it towards a corner by zugzwang.
Indeed.
Is this the correct description of the rules (http://www.chessvariants.com/large.dir/british.html)?
The only other real complication I see with it is the presence of knightriders/dabbabariders/alfilriders among the pieces. Guess I'll finally be adding those too.

There's a question about interfacing with XBoard. Promotion is to knight or captures piece, which I guess means using "great" as a parent variant, and stuffing pieces into FEN holdings so XBoard will understand they're supposed to be there? I think SjaakII will just ignore holdings if the game doesn't actually use them, and it never needs pass a generated FEN to XBoard, so I guess that's ok.
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by hgm »

I suppose the engine can calculate from the material on the board what pieces are available for promotion (assuming it was not a handicap game). The holdings display is indeed only an aid for the user, and can be stuffed with Knights like in the Great Shatranj start position it is stuffed with 'Soldiers'.

Indeed that link was the description that I found. Not sure why the inventor thought this would need an enlarged variant; it seems to me the theme and basic concept would have worked well on 8x8 with just altered Q, K and B too. Perhaps he felt that allocating the Queen to a different job would leave the game without super-piece.

The passing-through-check rule can actually be seen as a form of e.p. capture, where any piece would be allowed to e.p. capture a Queen. This would explain why you can do QxQ through check, as this would be equivalent to K x protected K in regular check, which is also allowed. There just is no recapture, not even e.p., after you lost your royal. Problem for Faiy-Max is that there can be an arbitrary number of e.p. squares. It was already so problematic to get the e.p. capture of triple pushes in Mexican Chess right (and it only works with boards of 10 ranks, by ignoring the lowest bit of the comparison between epSquare and toSquare there).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

hgm wrote:I suppose the engine can calculate from the material on the board what pieces are available for promotion (assuming it was not a handicap game).
Indeed. Actually SjaakII has restrictions for the number of pieces of a particular type that are allowed to exist at the same time (default is 128 for normal pieces, 1 for a royal piece). Promotions that put you over this are not generated.
Indeed that link was the description that I found. Not sure why the inventor thought this would need an enlarged variant; it seems to me the theme and basic concept would have worked well on 8x8 with just altered Q, K and B too. Perhaps he felt that allocating the Queen to a different job would leave the game without super-piece.
Maybe he tried to make Britain Great?
Having too many superpieces on an 8x8 board always feels cramped, but on 10x10 the queen doesn't feel so strong anymore. None of the new pieces appear overpowered on 8x8 though. Perhaps the Bishop/Nightrider compound comes closestto benefitting from the larger board.
The passing-through-check rule can actually be seen as a form of e.p. capture, where any piece would be allowed to e.p. capture a Queen. This would explain why you can do QxQ through check, as this would be equivalent to K x protected K in regular check, which is also allowed. There just is no recapture, not even e.p., after you lost your royal. Problem for Faiy-Max is that there can be an arbitrary number of e.p. squares. It was already so problematic to get the e.p. capture of triple pushes in Mexican Chess right (and it only works with boards of 10 ranks, by ignoring the lowest bit of the comparison between epSquare and toSquare there).
That's a useful analogy. I keep track of en-passant capture squares with a bitboard of "in-between" squares from the last move. Sadly I don't think I can reuse that directly because there are actual en-passant captures in there too...
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by hgm »

Well, you could pass an extra variable 'maxEpCapturer', which would represent the highest piece allowed to make such captures. After a Pawn move that would just be Pawns (assuming this is the lowest piece type). After a King move it would be every type. The e.p. squares (by definition empty) represent virtual targets, i.e. an capture-capable move of an e.p.-capable piece that goes there makes the capture, shifting the victim square from its own to-square to that of the previous mover.

Note that this also takes care of castling through check in orthodox Chess (or Chess960).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

Evert wrote: Indeed.
Is this the correct description of the rules (http://www.chessvariants.com/large.dir/british.html)?
The only other real complication I see with it is the presence of knightriders/dabbabariders/alfilriders among the pieces. Guess I'll finally be adding those too.
I seem to have something that works (it's not flexible enough though, since it only handles a single atom at the moment). Are there any good test positions for Nightrider chess?
I used the orthochess starting position, with Nightriders replacing Knights. Playing games seems to go fine, but I can't easily find other engines that play this, nor can I find perft numbers. For the latter I get

Code: Select all

 1         24  0.00     49586.78nps
 2        576  0.00    361809.05nps
 3      15586  0.00   3131605.38nps
 4     418926  0.19   2183623.58nps
 5   12268720  2.74   4471402.81nps
 6  358889842 69.32   5177296.66nps
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

Found one engine that plays it, Ferdinand Mosca's Masipag. Here's a test game:

[pgn][Event "Computer Chess Game"]
[Site "vivaine.local"]
[Date "2016.10.08"]
[Round "-"]
[White "Sjaak II 633"]
[Black "Masipag v1.1 32bit"]
[Result "1-0"]
[TimeControl "40/10"]
[Variant "fairy"]
[VariantMen "P:fmWfceFifmW2;B:B;R:R;Q:Q;N:N0;K:KisO2"]
[FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"]
[SetUp "1"]

{--------------
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
white to play
--------------}
1. d3 {+0.02/7} d6 {-0.08/7 0.2} 2. e4 {+0.23/7 0.1} Nd7 {-0.03/7 0.2} 3.
Nxd7 {+0.38/9 0.2} Qxd7 {-0.83/8 0.2} 4. Be3 {+0.52/7 0.2} Nf6
{-0.58/8 0.2} 5. Nc3 {+0.70/7 0.2} Qg4 {-0.70/7 0.2} 6. Bxa7 {+1.04/7 0.2}
Bd7 {-0.69/7 0.2} 7. h3 {+1.19/8 0.2} Qxd1+ {-0.52/8 0.2} 8. Kxd1
{+1.03/7 0.1} b6 {-0.60/8 0.2} 9. a4 {+1.19/7 0.2} g6 {-0.65/8 0.2} 10. a5
{+1.19/7 0.1} bxa5 {-0.69/8 0.2} 11. Rxa5 {+1.01/8 0.3} Bh6 {-0.74/9 0.2}
12. Ra3 {+1.14/7 0.2} e5 {-0.67/9 0.2} 13. Be2 {+1.06/7 0.2} O-O
{-0.43/9 0.2} 14. Nd5 {+1.01/7 0.2} Nxd5 {-0.50/9 0.2} 15. exd5
{+1.08/9 0.2} f6 {-0.98/10 0.2} 16. Bf3 {+1.13/9 0.1} Kg7 {-1.02/11 0.2}
17. h4 {+1.26/8 0.2} Bb5 {-0.75/9 0.2} 18. c4 {+1.42/8 0.2} Bd7
{-1.20/12 0.2} 19. Kc2 {+1.58/8 0.3} Bf4 {-1.24/11 0.2} 20. g3
{+1.55/10 0.3} Bh6 {-1.39/11 0.2} 21. Rha1 {+1.55/9 0.2} g5 {-1.30/10 0.2}
22. Be3 {+1.52/8 0.3} Rxa3 {-1.34/12 0.2} 23. Rxa3 {+1.44/10 0.2} g4
{-1.37/11 0.2} 24. Bxh6+ {+1.37/11 0.3} Kxh6 {-1.37/12 0.1} 25. Bh1
{+1.43/11 0.2} Kg6 {-1.35/12 0.3} 26. Ra7 {+1.39/10 0.3} Rc8 {-1.42/11 0.3}
27. c5 {+1.70/10 0.3} Bb5 {-1.17/11 0.3} 28. c6 {+1.76/10 0.2} f5
{-1.21/12 0.3} 29. f3 {+1.65/10 0.2} Kh5 {-0.95/11 0.3} 30. Rb7
{+1.85/11 0.2} Ba6 {-1.01/13 0.3} 31. Rb4 {+1.80/11 0.3} gxf3
{-1.02/12 0.3} 32. Bxf3+ {+1.88/11 0.3} Kh6 {-1.23/13 0.3} 33. Ra4
{+1.86/12 0.2} Bb5 {-0.98/14 0.3} 34. Ra5 {+1.79/12 0.2} Bxd3+
{-1.16/13 0.3} 35. Kxd3 {+1.76/12 0.3} Rg8 {-1.22/15 0.3} 36. Ke2
{+1.92/14 0.2} Rxg3 {-1.22/14 0.3} 37. Ra7 {+2.12/14 0.3} Rg7
{-1.03/14 0.2} 38. b4 {+3.28/13 0.3} e4 {-3.73/12 0.3} 39. Bh1
{+3.91/14 0.6} Rg4 {-2.59/13 0.3} 40. Rxc7 {+4.95/14 0.6} Rxh4
{-2.52/11 0.4} 41. Bg2 {+5.12/12 0.2} Rh2 {-4.74/11 0.2} 42. Kf1
{+5.28/13 0.3} e3 {-4.62/11 0.2} 43. Re7 {+5.33/12 0.2} Rh4 {-4.74/11 0.2}
44. b5 {+6.48/11 0.5} Rb4 {-4.83/9 0.2} 45. c7 {+7.67/10 0.2} Rc4
{-9.07/11 0.2} 46. Re6+ {+6.78/9 0.4} Kg5 {-9.01/11 0.2} 47. b6
{+6.94/10 0.2} Kf4 {-9.70/10 0.2} 48. Rxd6 {+7.64/10 0.2} Rc1+
{-10.70/10 0.2} 49. Ke2 {+5.93/2 0.1} Rc2+ {-12.26/10 0.2} 50. Kd3
{+10.06/9 0.3} Rd2+ {-12.26/9 0.2} 51. Kc3 {+10.88/9 0.1} Rd1
{-14.20/10 0.2}
{Black Resigns} 1-0
[/pgn]
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Can Sjaak II do British Chess (aka Caissa Brittania)?

Post by Evert »

Ok, I have something that should work, but it has issues. I'm not entirely happy with the way I do the "en-passant check" test at the moment: I now do it when generating moves so that it never generates these moves. This is more efficient if you end up searching more than one Queen move (because it can bulk-test moves), but obviously less so if you get a cut-off before searching a Queen move. It doesn't take the path taken into account, so a royal would also be prevented from leaping over attacked squares (as opposed to sliding through them). All of this can of course be fixed later.

The main issue I run into is with XBoard though. Cosmetically, I just can't figure out how to get the small lion and flying dragon pictographs (for the Lion and Dragon pieces). I seem to remember this being easier, but now when I try it I either get a different pictograph, or XBoard crashes.

Other than those:

In this position, dr1b1k4/10/pp3pq2p/2pD2p3/3pp5/1P8/4P1BP2/PP1P2P1RP/6K2d/1RQ7 b - 2 24, XBoard refuses the move "f7f5", which is legal.
In this position, 10/1B8/1p1p2qp1p/6l2r/4pb1B2/1P5P1P/8P1/P1P2PQ3/10/D9 b - 6 36, it refuses the move "g7e7", which is again legal.

Piece moves are sent as

Code: Select all

13450 <second&#58; piece N& N
13450 <second&#58; piece U& BN0
13450 <second&#58; piece D& D0A0
13450 <second&#58; piece L& mQcpQ
13450 <second&#58; piece B& BmW
13450 <second&#58; piece R& R
13450 <second&#58; piece Q& Q
13450 <second&#58; piece K& K
13450 <second&#58; piece P& fmWfceFifmW2
EDIT: one more, 6q3/3k6/p2p3d2/p1p7/10/1P1P1uD3/9P/10/6u2Q/10 b - 9 70, the move h7b1 is refused.