Stockfish 7 and partial 6 piece syzygy problem?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Jouni
Posts: 3281
Joined: Wed Mar 08, 2006 8:15 pm

Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni »

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 Ng6
+- (2.82) Depth: 40/56 00:00:10 224mN

Analysis by Komodo 9.2 64-bit:

1.Ke6 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jouni
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy »

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: 684
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by petero2 »

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: 3281
Joined: Wed Mar 08, 2006 8:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni »

Thanks Peter. Hopefully somebody sends fix to Github also.
Jouni
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy »

petero2 wrote:Here is a fix:
Yes, that is a good fix.
It might indeed have caused what Jouni observed.
Jouni
Posts: 3281
Joined: Wed Mar 08, 2006 8:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni »

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: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by syzygy »

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: 2041
Joined: Wed Mar 08, 2006 8:30 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by ernest »

syzygy wrote:Well, you're not really supposed to use incomplete sets :)
Well, I certainly agree with that, especially for syzygy !!!
Jouni
Posts: 3281
Joined: Wed Mar 08, 2006 8:15 pm

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by Jouni »

I see there has been syzygy rewriting lately. May be this can be fixed at the same time?
Jouni
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Stockfish 7 and partial 6 piece syzygy problem?

Post by bob »

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.