Porting syzgy/tb to an old version chess (shatranj)

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

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

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by hgm »

syzygy wrote: Sun Sep 29, 2024 4:06 pmI have not extensively tested stalemate, etc.
Try if it sees the following position as a win in 1:

[d]8/8/8/8/8/8/p7/k2K3F w

And
[d]7R/8/8/8/8/K7/8/kf6 w
noobpwnftw
Posts: 617
Joined: Sun Nov 08, 2015 11:10 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by noobpwnftw »

syzygy wrote: Sun Sep 29, 2024 4:06 pm
noobpwnftw wrote: Sun Sep 29, 2024 7:26 am I'll do the full 6 men tables with your generator.

https://www.chessdb.cn/egtb_infoj.html

Files will be shared after they are built.
Nice. I hope the generator is now fully correct. I have not extensively tested stalemate, etc.

There should be 360 tables with 4/5/6 pioeces (15/75/270).
A slight inconvenence is that PCHR should be ordered differently to reflect piece values but I guess this is not significant or worth to be special.
syzygy
Posts: 5647
Joined: Tue Feb 28, 2012 11:56 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by syzygy »

noobpwnftw wrote: Sun Sep 29, 2024 5:34 pm
syzygy wrote: Sun Sep 29, 2024 4:06 pm
noobpwnftw wrote: Sun Sep 29, 2024 7:26 am I'll do the full 6 men tables with your generator.

https://www.chessdb.cn/egtb_infoj.html

Files will be shared after they are built.
Nice. I hope the generator is now fully correct. I have not extensively tested stalemate, etc.

There should be 360 tables with 4/5/6 pioeces (15/75/270).
A slight inconvenence is that PCHR should be ordered differently to reflect piece values but I guess this is not significant or worth to be special.
It looks like-Fairy Stockfish uses the same letters, i.e. Q for the ferz and B for the alfil:
https://github.com/fairy-stockfish/Fair ... #L231-L255
In Shatranj promotions are always to Ferz, so that would be an argument for ranking the Ferz highest.

Fairy-Stockfish seems to use a 70-move rule. Is this some kind of generally agreed upon rule for Shatranj? If so, it would make sense to use the same rule for Shatranj tablebases.
syzygy
Posts: 5647
Joined: Tue Feb 28, 2012 11:56 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by syzygy »

syzygy wrote: Sun Sep 29, 2024 6:36 pmFairy-Stockfish seems to use a 70-move rule. Is this some kind of generally agreed upon rule for Shatranj? If so, it would make sense to use the same rule for Shatranj tablebases.
https://www.abstractgames.org/shatranj1.html
The rules of Shatranj are the same as the standard Western game, with the same setup, except for the following:
  • The game is won by checkmate, by capturing all opposing pieces except the enemy King, or by stalemate.
  • The Bishop is replaced by the Elephant, which jumps two squares diagonally. This piece is still present in XiangQi.
  • The Queen is replaced by the Fers (Advisor) that moves one square diagonally. This piece is still to be found in both Thai Makruk and XiangQi.
  • The Pawn moves only one square, even on its first move. There is no en passant.
  • When the Pawn reaches the last row, it automatically becomes a Fers. Multiple Ferses are allowed.
  • There is no castling.
  • Instead of the 50 move draw rule, there is a 70 move draw rule (Hooper and Whyld, 1992). In other words, a player can claim a draw if each player has made 70 moves, during which no capture has been made and no Pawn has been moved.
noobpwnftw
Posts: 617
Joined: Sun Nov 08, 2015 11:10 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by noobpwnftw »

Don't care, can do the 70-move rule.
syzygy
Posts: 5647
Joined: Tue Feb 28, 2012 11:56 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by syzygy »

Unfortunately, simply changing DRAW_RULE in the generator from (2 * 50) to (2 * 70) does not work.

The problem is that the values stored in the table no longer fit in a byte, so a "reduction" step has to be done before the "N-move rule" is reached. Not a major problem but it needs some work.
noobpwnftw
Posts: 617
Joined: Sun Nov 08, 2015 11:10 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by noobpwnftw »

It would be easier to use 2 bytes per pos without precision issue.
syzygy
Posts: 5647
Joined: Tue Feb 28, 2012 11:56 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by syzygy »

noobpwnftw wrote: Sun Sep 29, 2024 7:21 pm It would be easier to use 2 bytes per pos without precision issue.
No need, the generation phase uses full precision with 1 byte per position by reducing all values every so many iterations. The information that is removed is stored to disk and everything is reconstructed later.

The compression step removes 1 bit of precision when there are no cursed positions, and for DTZ values > 100 (or 140).
I could add a switch that does not remove this bit for positions with DTZ <= 100 (/140) at the cost of some extra storage space (only DTZ is affected, so I guess extra storage space does not really matter). Probing code would not be affected.
noobpwnftw
Posts: 617
Joined: Sun Nov 08, 2015 11:10 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by noobpwnftw »

Nice, extra disk or memory isn't relevant here if we are just doing some small tables.
noobpwnftw
Posts: 617
Joined: Sun Nov 08, 2015 11:10 pm

Re: Porting syzgy/tb to an old version chess (shatranj)

Post by noobpwnftw »

Full 6-men dtz50 shatranj syzygy tb is built:
ftp://chessdb:chessdb@ftp.chessdb.cn/pu ... /shatranj/