Stockfish 7 and partial 6 piece syzygy problem?

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.
Jouni
Posts: 2005
Joined: Wed Mar 08, 2006 7:15 pm

Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni » Tue Mar 01, 2016 12:54 pm

I installed some interesting 6 piece bases (both files of course). After test runs I noticed a problem.
If there is 6 piece position on board, but no corresponding tablebase engine is not using any syzy at all! Komodo is more clever here.

Example 1:

[D]6B1/5P2/5Knk/8/7P/8/8/8 w - - 0 1


Analysis by Stockfish 7 64 BMI2:


1.h5 Nf8 2.Ke7 Kg7 3.Ke8 Ne6 4.h6+ Kh8 5.Kd7 Nf8+ 6.Kd8 Ng6 7.Kc7 Nf8 8.Kb6 Ne6 9.Kb5 Nf8 10.Kc5 Ng6 11.Kd6 Nf8 12.Ke7 Ng6+ 13.Kd8 Nf8 14.Kc7 Ne6+ 15.Kc8 Nf8 16.Kb7 Ne6 17.Kb8 Nf8 18.Ka7 Ne6 19.Kb6 Nf8 20.Kc6 Ne6 21.Kd5 Nf8 22.Ke5 Ng6+ 23.Kf5 Nf8 24.Kf6 Nd7+ 25.Kg5 Nf8 26.Kf4 Nd7 27.Ke4 Nf8
+- (2.82) Depth: 39/54 00:00:07 168mN
1.h5 Nf8 2.Ke7 Kg7 3.Ke8 Ne6 4.h6+ Kh8 5.Kd7 Nf8+ 6.Kd8 Ng6 7.Kc7 Nf8 8.Kb6 Ne6 9.Kb5 Nf8 10.Kc5 Ng6 11.Kd6 Nf8 12.Ke7 Ng6+ 13.Kd8 Nf8 14.Kc7 Ne6+ 15.Kc8 Nf8 16.Kb7 Ne6 17.Kb8 Nf8 18.Ka7 Ne6 19.Kb6 Nf8 20.Kc6 Ne6 21.Kd5 Nf8 22.Ke5 Ng6+ 23.Kf5 Nf8 24.Kf6 Nd7+ 25.Kg5 Nf8 26.Kf4 Nd7 27.Ke4 Nf8 28.Kd5 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493450


With 5 piece syzygy SF solves positions correct. Maybe this is easily fixable so You can use 6 piece syzygy without full 150 GB set?
Jouni

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

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy » Wed Mar 02, 2016 9:09 pm

Jouni wrote:If there is 6 piece position on board, but no corresponding tablebase engine is not using any syzy at all!
That is not true.

SF simply fails to find the win in these two positions.

petero2
Posts: 587
Joined: Mon Apr 19, 2010 5:07 pm
Location: Sweden
Contact:

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by petero2 » Thu Mar 03, 2016 5:50 am

Jouni wrote:I installed some interesting 6 piece bases (both files of course). After test runs I noticed a problem.
If there is 6 piece position on board, but no corresponding tablebase engine is not using any syzy at all!
...
With 5 piece syzygy SF solves positions correct. Maybe this is easily fixable so You can use 6 piece syzygy without full 150 GB set?
I can reproduce the problem in stockfish 7 in droidfish. Here is a fix:

Code: Select all

--- a/search.cpp
+++ b/search.cpp
@@ -271,7 +271,7 @@
               TB::RootInTB = Tablebases::root_probe_wdl(rootPos, rootMoves, TB::Score);
 
               // Only probe during search if winning
-              if &#40;TB&#58;&#58;Score <= VALUE_DRAW&#41;
+              if &#40;TB&#58;&#58;RootInTB && TB&#58;&#58;Score <= VALUE_DRAW&#41;
                   TB&#58;&#58;Cardinality = 0;
           &#125;
 

Jouni
Posts: 2005
Joined: Wed Mar 08, 2006 7:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni » Thu Mar 03, 2016 9:31 am

Thanks Peter. Hopefully somebody sends fix to Github also.
Jouni

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

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy » Thu Mar 03, 2016 9:11 pm

petero2 wrote:Here is a fix:
Yes, that is a good fix.
It might indeed have caused what Jouni observed.

Jouni
Posts: 2005
Joined: Wed Mar 08, 2006 7:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni » Mon Mar 07, 2016 10:31 am

Will there be a fix soon? Finding this bug took me just 1 minute, because first position was number 3 in AH_endgames.
Jouni

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

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy » Tue Mar 08, 2016 12:37 am

Jouni wrote:Will there be a fix soon? Finding this bug took me just 1 minute, because first position was number 3 in AH_endgames.
Well, you're not really supposed to use incomplete sets :)

Whether it will be fixed soon depends on the SF maintainers (and whether someone submits a patch, I guess).

ernest
Posts: 1860
Joined: Wed Mar 08, 2006 7:30 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by ernest » Tue Mar 08, 2016 7:35 pm

syzygy wrote:Well, you're not really supposed to use incomplete sets :)
Well, I certainly agree with that, especially for syzygy !!!

Jouni
Posts: 2005
Joined: Wed Mar 08, 2006 7:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni » Thu Sep 01, 2016 6:23 pm

I see there has been syzygy rewriting lately. May be this can be fixed at the same time?
Jouni

bob
Posts: 20555
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by bob » Thu Sep 01, 2016 7:01 pm

Jouni wrote:I see there has been syzygy rewriting lately. May be this can be fixed at the same time?
This has been a general problem for so long... With nalimov if you are in a KRPKR ending and you do not have KRQKR, you will have a problem. You will avoid promoting since with the pawn on the board, you see a mate-in-N score, but after the promotion you would only see a queen advantage or so, so you don't promote.

With the 6 piece syzygy's being so small, what would be the reason for having an incomplete set? You are introducing overhead. Why try to probe a table you don't have in the first place???

If I were Ronald, I would probably just fix the initialization code so that it would not try to use any 6 piece files unless ALL 6 piece files are available, then this kind of problem goes away.

Post Reply