## 7-men Syzygy attempt

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.
noobpwnftw
Posts: 340
Joined: Sun Nov 08, 2015 10:10 pm

### 7-men Syzygy attempt

So with some fiddling and help from https://github.com/jjoshua2/tb/

It seems at least some of the 7-men TBs can be produced. Here is the current code: https://github.com/noobpwnftw/tb/tree/7-men, and here are all 3-6 men + some 7 men TBs I've generated so far: ftp://112.73.74.24/pub/syzygy/

However, it failed at this line https://github.com/noobpwnftw/tb/blob/a ... ute.c#L552 when generating certain piece combinations, for example KQQRBNvK.

Logs here:

Code: Select all

``````./rtbgen -t 128 --disk KQQRBNvK
Found 533 tablebases.
number of threads = 128
Initialising broken positions.
time taken =   0&#58;31.838
Calculating white captures.
time taken =   0&#58;17.572
Calculating black captures.
time taken =   0&#58;04.970
time taken =   0&#58;06.162
time taken =   0&#58;06.358
time taken =   0&#58;10.668
time taken =   0&#58;13.659
time taken =   0&#58;26.850
Calculating mate positions.
time taken =   1&#58;28.989
Iteration 1 ... done.
Iteration 2 ... done.
Iteration 3 ... done.
Iteration 4 ... done.
Iteration 5 ... done.
Iteration 6 ...
########## KQQRBNvK ##########

White to move&#58;

50353929224 positions win in 1 ply.
19485324695 positions win in 2 ply.
28225943789 positions win in 3 ply.
1549221184 positions win in 4 ply.
243517440 positions win in 5 ply.
508342 positions win in 6 ply.
1236 positions win in 7 ply.

99858445910 positions are wins.
10832 positions are draws.
0 positions are losses.

Black to move&#58;

0 positions are wins.
13398181230 positions are draws.
337200714690 positions are losses.

40252520554 positions lose in 0 ply.
23613041816 positions lose in 1 ply.
130186914772 positions lose in 2 ply.
54678294580 positions lose in 3 ply.
81532772392 positions lose in 4 ply.
5908260412 positions lose in 5 ply.
1026861706 positions lose in 6 ply.
2041596 positions lose in 7 ply.
6862 positions lose in 8 ply.

Longest win for white&#58; 8 ply; 8/Q1R5/8/8/3N4/2B5/5k2/QK6 b - -

tb_size = 196209130320
find optimal permutation for wtm / wdl
&#91; 0&#93; order&#58; 2; perm&#58;  2  3  4  6 14  5; 8000
&#91; 1&#93; order&#58; 2; perm&#58;  2  4  3  6 14  5; 8011
&#91; 2&#93; order&#58; 2; perm&#58;  2  6  3  4 14  5; 8000
&#91; 3&#93; order&#58; 2; perm&#58;  2 14  3  4  6  5; 8000
&#91; 4&#93; order&#58; 2; perm&#58;  3  2  4  6 14  5; 8000
&#91; 5&#93; order&#58; 2; perm&#58;  4  2  3  6 14  5; 8012
&#91; 6&#93; order&#58; 2; perm&#58;  6  2  3  4 14  5; 8000
&#91; 7&#93; order&#58; 2; perm&#58; 14  2  3  4  6  5; 8000
&#91; 8&#93; order&#58; 2; perm&#58;  3  4  2  6 14  5; 8011
&#91; 9&#93; order&#58; 2; perm&#58;  3  6  2  4 14  5; 8000
&#91;10&#93; order&#58; 2; perm&#58;  3 14  2  4  6  5; 8000
&#91;11&#93; order&#58; 2; perm&#58;  4  3  2  6 14  5; 8006
&#91;12&#93; order&#58; 2; perm&#58;  6  3  2  4 14  5; 8000
&#91;13&#93; order&#58; 2; perm&#58; 14  3  2  4  6  5; 8000
&#91;14&#93; order&#58; 2; perm&#58;  4  6  2  3 14  5; 8000
&#91;15&#93; order&#58; 2; perm&#58;  4 14  2  3  6  5; 8000
&#91;16&#93; order&#58; 2; perm&#58;  6  4  2  3 14  5; 8000
&#91;17&#93; order&#58; 2; perm&#58; 14  4  2  3  6  5; 8000
&#91;18&#93; order&#58; 2; perm&#58;  6 14  2  3  4  5; 8000
&#91;19&#93; order&#58; 2; perm&#58; 14  6  2  3  4  5; 8000
&#91;20&#93; order&#58; 3; perm&#58;  3  5  6  2  4 14; 8000
&#91;21&#93; order&#58; 3; perm&#58;  6  5 14  3  2  4; 8000
&#91;22&#93; order&#58; 3; perm&#58; 14  5  6  3  2  4; 8000
&#91;23&#93; order&#58; 3; perm&#58;  2  5  6 14  3  4; 8000
&#91;24&#93; order&#58; 3; perm&#58;  4  5  6 14  2  3; 8000
&#91;25&#93; order&#58; 3; perm&#58;  5  6  2  4  3 14; 8000
&#91;26&#93; order&#58; 3; perm&#58;  5 14  2  4  3  6; 8000
&#91;27&#93; order&#58; 3; perm&#58;  5  2  6 14  3  4; 8000
&#91;28&#93; order&#58; 3; perm&#58;  5  3  4  6  2 14; 8000
&#91;29&#93; order&#58; 3; perm&#58;  5  4  6  2  3 14; 8000
&#91; 0&#93; order&#58; 2; perm&#58;  2  3  6  4 14  5; 8000
&#91; 1&#93; order&#58; 2; perm&#58;  2  3 14  4  6  5; 8000
&#91; 2&#93; order&#58; 2; perm&#58;  2  4  6  3 14  5; 8000
&#91; 3&#93; order&#58; 2; perm&#58;  2  4 14  3  6  5; 8000
&#91; 4&#93; order&#58; 2; perm&#58;  2  6  4  3 14  5; 8000
&#91; 5&#93; order&#58; 2; perm&#58;  2 14  4  3  6  5; 8000
&#91; 6&#93; order&#58; 2; perm&#58;  2  6 14  3  4  5; 8000
&#91; 7&#93; order&#58; 2; perm&#58;  2 14  6  3  4  5; 8005
&#91; 8&#93; order&#58; 3; perm&#58;  2  4  5  6 14  3; 8000
&#91; 9&#93; order&#58; 3; perm&#58;  2  3  5  6  4 14; 8000
&#91;10&#93; order&#58; 3; perm&#58;  2  6  5  3  4 14; 8000
&#91;11&#93; order&#58; 3; perm&#58;  2 14  5  3  4  6; 8000
&#91;12&#93; order&#58; 3; perm&#58;  2  5 14  6  3  4; 8000
&#91;13&#93; order&#58; 3; perm&#58;  2  5  3  6  4 14; 8000
&#91;14&#93; order&#58; 3; perm&#58;  2  5  4  3  6 14; 8000
Segmentation fault
``````

I think the current piece encoding/decoding cannot handle cases of KKQRBN+X(which did not exist in 6 men).

I recall there was a thread here where its author Ronald explained the detailed mechanisms with mcostalba, but no luck with the search... any enlightenment is appreciated.

noobpwnftw
Posts: 340
Joined: Sun Nov 08, 2015 10:10 pm

### Re: 7-men Syzygy attempt

Also I tried building KRBNvKQN which has the longest mate among pawnless 7-men TBs, the step counter should overflow:

Code: Select all

``````Iteration 241 ... done.
...omitted...
Iteration 299 ... done.
Iteration 300 ... find_val&#58; not found!``````
There is REDUCE_PLY which I believe halves the counter past it, but I strongly suspect it is not normal to see a longest mate index not found.

Vinvin
Posts: 4369
Joined: Thu Mar 09, 2006 8:40 am
Full name: Vincent Lejeune

### Re: 7-men Syzygy attempt

noobpwnftw wrote:... when generating certain piece combinations, for example KQQRBNvK.
...
Please, don't generate 6 pieces vs a lone king. + they are useless to generate other endings.

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

### Re: 7-men Syzygy attempt

Vinvin wrote:
noobpwnftw wrote:... when generating certain piece combinations, for example KQQRBNvK.
...
Please, don't generate 6 pieces vs a lone king. + they are useless to generate other endings.
Not useless.
Fast to generate and I have a friend who is very keen to examine the statistics.
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.

noobpwnftw
Posts: 340
Joined: Sun Nov 08, 2015 10:10 pm

### Re: 7-men Syzygy attempt

Found the thread:
http://www.talkchess.com/forum/viewtopic.php?t=59947

And the crash above seems to be the tb_size calculation from permute type 0 is not the largest possible in trylist.

syzygy
Posts: 4451
Joined: Tue Feb 28, 2012 10:56 pm

### Re: 7-men Syzygy attempt

noobpwnftw wrote:I think the current piece encoding/decoding cannot handle cases of KKQRBN+X(which did not exist in 6 men).
The encoding/decoding scheme in principle can deal with that, but there may be a 32-bit overflow in an intermediate calculation.

syzygy
Posts: 4451
Joined: Tue Feb 28, 2012 10:56 pm

### Re: 7-men Syzygy attempt

noobpwnftw wrote:Also I tried building KRBNvKQN which has the longest mate among pawnless 7-men TBs, the step counter should overflow:

Code: Select all

``````Iteration 241 ... done.
...omitted...
Iteration 299 ... done.
Iteration 300 ... find_val&#58; not found!``````
There is REDUCE_PLY which I believe halves the counter past it, but I strongly suspect it is not normal to see a longest mate index not found.
I'm not sure why this happens.

There will indeed be problems with very long mates, but the generation part should be able to deal with them. The problem comes when compressing (too many possible values). I have basically solved that problem when implementing DTM, but that code has not yet been added to github. The solution will require a small change in the format too.

syzygy
Posts: 4451
Joined: Tue Feb 28, 2012 10:56 pm

### Re: 7-men Syzygy attempt

noobpwnftw wrote:And the crash above seems to be the tb_size calculation from permute type 0 is not the largest possible in trylist.
They all have the same size/index range.

noobpwnftw
Posts: 340
Joined: Sun Nov 08, 2015 10:10 pm

### Re: 7-men Syzygy attempt

The encoding/decoding scheme in principle can deal with that, but there may be a 32-bit overflow in an intermediate calculation.
Thank you for this information, then I will look into it and see if I can fix the index calculation overflow first.
They all have the same size/index range.
Indeed, they are of the same size.

noobpwnftw
Posts: 340
Joined: Sun Nov 08, 2015 10:10 pm

### Re: 7-men Syzygy attempt

int overflow happened with the factor[] array, now it seems to be working!