7-man Syzygy support in Fathom

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.
Post Reply
jdart
Posts: 3825
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

7-man Syzygy support in Fathom

Post by jdart » Tue Apr 23, 2019 2:55 am

I have pushed a branch with changes to support 7-man tbs, here:

https://github.com/jdart1/Fathom/tree/7man

The approach I took was to take the Cfish code, which supports 7-man TBs, and merge it into Fathom. This is not the only way to do it and maybe not even the easiest, but that's the path I took. The main changes were to strip out the dependencies the Cfish tbprobe.c file had on the rest of Cfish, and to graft into it the simpler board representation, move generation and other chess-related code that was in Fathom. There are a few small macros and definitions imported from Cfish, but not much.

My objectives were to:
1. Preserve the existing Fathom interface.
2. Add methods to the interface to support the Cfish approach of returning an array of moves with scores and ranks for root level DTZ and WDL probes.
3. Enable compilation under C99 and C++ as in the original Fathom. However, now C++11 is required, at least to the extent that "atomic" variable support is not optional.

The code has been restructured a bit - I have put all the move generation stuff and defines related to the chess pieces, colors, etc. in tbchess.c. I considered doing some work to actually make this pluggable so that you could easily substitute in a different move generator implementation if you had one, but I have not done that. tbprobe.c now contains all the probing code. The Cfish code and part of the original Fathom code were unlicensed ("This file may be redistributed and/or modified without restrictions"), but my fork is MIT licensed, including this branch. (The Stockfish tablebase code is much nicer--it is all C++11 and very well commented, but that's GPL and so I have not used any of it).

This branch now passes all the tablebase unit tests I have in the Arasan code, which are not very extensive but cover a number of important corner cases.

By the way, also, it fixes a couple of bugs: one of them was fathom.c failing to display en passant captures correctly. Also, I am pretty sure the main branch of Fathom does not actually work on big-endian architectures but this new code should, although I have not tested in that environment.

However, I don't think it is quite ready for production use, for a couple of reasons:
1. Hasn't yet been tested on non-Linux platforms including Windows.
2. I have done very limited testing with 7-man bases. I don't have storage for a full set.

I am going to do a little more testing and cleanup before merging into the main branch. Feedback/additional testing welcome.

--Jon

Dann Corbit
Posts: 10124
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: 7-man Syzygy support in Fathom

Post by Dann Corbit » Tue Apr 23, 2019 8:45 am

jdart wrote:
Tue Apr 23, 2019 2:55 am
I have pushed a branch with changes to support 7-man tbs, here:

https://github.com/jdart1/Fathom/tree/7man
{snip}
I am going to do a little more testing and cleanup before merging into the main branch. Feedback/additional testing welcome.

--Jon
Thank you for this marvelous effort, so that others can use it for chess engines, EGTB servers, etc.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

jdart
Posts: 3825
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: 7-man Syzygy support in Fathom

Post by jdart » Tue Apr 23, 2019 2:42 pm

Code compiles/runs under Windows now.

--Jon

elcabesa
Posts: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: 7-man Syzygy support in Fathom

Post by elcabesa » Tue Apr 23, 2019 2:46 pm

jdart wrote:
Tue Apr 23, 2019 2:55 am
I have pushed a branch with changes to support 7-man tbs, here:
I Jon,
I have some small patch to your 6man code that will correct some warning reported by the compiler.

where can I send it? shall I fork your repository and create a pull request? os shall I send a patch file?

jdart
Posts: 3825
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: 7-man Syzygy support in Fathom

Post by jdart » Tue Apr 23, 2019 3:48 pm

Probably best to fork it/send a pull request.

--Jon

elcabesa
Posts: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: 7-man Syzygy support in Fathom

Post by elcabesa » Tue Apr 23, 2019 4:01 pm

I'll try

elcabesa
Posts: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: 7-man Syzygy support in Fathom

Post by elcabesa » Tue Apr 23, 2019 4:30 pm

jdart wrote:
Tue Apr 23, 2019 3:48 pm
Probably best to fork it/send a pull request.

--Jon
done, please check it :)

jdart
Posts: 3825
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: 7-man Syzygy support in Fathom

Post by jdart » Wed Apr 24, 2019 5:26 pm

I have made most of elcabesa's proposed fixes and merged the "7man" branch into "master."

--Jon

Dann Corbit
Posts: 10124
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: 7-man Syzygy support in Fathom

Post by Dann Corbit » Fri Apr 26, 2019 5:15 am

I only have 6 man files here (I will test 7 man later) but it builds and runs fine both with clang and with gcc. I had to add an -I. to the makefile.

Code: Select all

F:\project\dcorbit\Fathom-master\src>fathom --path=c:\chess\syzygy "R7/8/5n2/P2r1k2/8/4K3/8/8 b - - 0 1"
[Event ""]
[Site ""]
[Date "??"]
[Round "-"]
[White "Syzygy"]
[Black "Syzygy"]
[Result "1/2-1/2"]
[FEN "R7/8/5n2/P2r1k2/8/4K3/8/8 b - - 0 1"]
[WDL "Draw"]
[DTZ "0"]
[WinningMoves ""]
[DrawingMoves "Kg4, Ke5, Kg5, Ke6, Kg6, Rd1, Rxa5, Rb5, Rc5, Re5, Rd6, Rd7, Ne4, Ng4, Nh5, Nd7, Nh7, Ne8, Ng8"]
[LosingMoves "Rd2, Rd3, Rd4, Rd8"]

1... Nd7 2. Ke2 Re5+ 3. Kd2 Nb6 4. Rb8 Nc8 5. Ra8 Nb6 6. Rb8 Nc8 7. Ra8 Nb6 8. Rb8 Nc8 9. Ra8 Nb6 10. Rb8 Nc8 11. Ra8 Nb6 12. Rb8 Nc8 13. Ra8 Nb6 14. Rb8 Nc8 15. Ra8 Nb6 16. Rb8 Nc8 17. Ra8 Nb6 18. Rb8 Nc8 19. Ra8 Nb6 20. Rb8 Nc8 21. Ra8 Nb6 22. Rb8 Nc8 23. Ra8 Nb6 24. Rb8 Nc8 25. Ra8 Nb6 26. Rb8 Nc8 27. Ra8 Nb6 28. Rb8 Nc8 29. Ra8 Nb6 30. Rb8 Nc8 31. Ra8 Nb6 32. Rb8 Nc8 33.
23 moves returned from DTZ probe
Kg4 rank = 0 score=0
Ke5 rank = 0 score=0
Kg5 rank = 0 score=0
Ke6 rank = 0 score=0
Kg6 rank = 0 score=0
Rd1 rank = 0 score=0
Rd2 rank = -1000 score=-31744
Rd3 rank = -1000 score=-31744
Rd4 rank = -1000 score=-31744
Rxa5 rank = 0 score=0
Rb5 rank = 0 score=0
Rc5 rank = 0 score=0
Re5 rank = 0 score=0
Rd6 rank = 0 score=0
Rd7 rank = 0 score=0
Rd8 rank = -1000 score=-31744
Ne4 rank = 0 score=0
Ng4 rank = 0 score=0
Nh5 rank = 0 score=0
Nd7 rank = 0 score=0
Nh7 rank = 0 score=0
Ne8 rank = 0 score=0
Ng8 rank = 0 score=0
23 moves returned from WDL probe
Kg4 rank = 0 score=0
Ke5 rank = 0 score=0
Kg5 rank = 0 score=0
Ke6 rank = 0 score=0
Kg6 rank = 0 score=0
Rd1 rank = 0 score=0
Rd2 rank = -1000 score=-31744
Rd3 rank = -1000 score=-31744
Rd4 rank = -1000 score=-31744
Rxa5 rank = 0 score=0
Rb5 rank = 0 score=0
Rc5 rank = 0 score=0
Re5 rank = 0 score=0
Rd6 rank = 0 score=0
Rd7 rank = 0 score=0
Rd8 rank = -1000 score=-31744
Ne4 rank = 0 score=0
Ng4 rank = 0 score=0
Nh5 rank = 0 score=0
Nd7 rank = 0 score=0
Nh7 rank = 0 score=0
Ne8 rank = 0 score=0
Ng8 rank = 0 score=0

F:\project\dcorbit\Fathom-master\src>
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

Post Reply