Stockfish-1.5 Detects mate then changes mind?

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

Moderator: Ras

royb
Posts: 572
Joined: Thu Mar 09, 2006 12:53 am

Stockfish-1.5 Detects mate then changes mind?

Post by royb »

In this position:

1q1r3k/3P1pp1/ppBR1n1p/4Q2P/P4P2/8/5PK1/8 w - - bm Rxf6;

I let Stockfish 1.5 analyze with two threads and the tail end of the analysis window shows this:

19 +1.57 1.Rd1 Qxe5 2.fxe5 Nxh5 3.Kf3 Kg8 4.Rh1 g6 5.Rb1 Kf8 6.Rxb6 Ke7 7.Rxa6 Ng7 8.Ke3 Ne6 9.Rb6 Nc5 10.a5 Nxd7 (23.50)
20 +1.37 1.Rd1 Qxe5 2.fxe5 Nxh5 3.Kf3 Kg8 4.Rh1 g6 5.Rb1 f6 6.e6 Kf8 7.Rxb6 Ke7 8.Bd5 f5 9.Ke3 a5 10.Kd4 Nf4 (41.34)
20 M12 1.Kf3 Kg8 2.Qe7 Qc7 3.Kg2 a5 4.f3 Qb8 5.Rxf6 gxf6 6.Bd5 Qc7 7.Qxf7+ Kh8 8.Qxf6+ Kh7 9.Kg3 Rxd7 10.Qg6+ Kh8 11.Qxh6+ Rh7 12.Qf8# (63.09)
21 +1.77 1.Kf3 Kg8 2.Qe7 Qc7 3.Kg2 Kh8 4.Rxf6 gxf6 5.Qxf6+ Kg8 6.Qxh6 Rxd7 7.Qg5+ Kf8 8.Bxd7 Qxd7 9.h6 Qd4 10.Kg3 Qd3+ 11.Kh2 Qd4 12.Kh3 Qd3+ 13.Kh4 Qd4 14.h7 Qh8 15.Qf5 (73.47)

Strange that at ply 20 it thinks 1. Kf3 is a mate in 12 but then with more time and another ply it thinks that Kf3 only scores 1.77 pawns.

It seems that once it detects mate in 12, surely the only other moves that are better are moves that mate more quickly? I suspect the mate in 12 is not accurate but I'm going to sleep now and will be unable to check it until much later on.

I have no reason to doubt that the stated best move (Rxf6) is the best and suspect the mate in 12 announcement is in error. A bug in Stockfish 1.5 ??

Roy
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Tord Romstad »

I can't reproduce this (which is not unexpected, as you were using two threads), but the general rule is that you can never trust the fail high scores reported by Stockfish, not even as lower bounds. You have to wait until the fail high is resolved, usually at the next iteration. Perhaps we should just display the upper boundary of the window instead of the score returned by the search when a fail high at the root occurs.

Joona's aspiration window search is highly unorthodox and frequently displays weird behavior. The only reason I like it is that it works incredibly well when playing games. :)

By the way, Stockfish 1.5 is no different from 1.4 in this respect.
Uri Blass
Posts: 10961
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Uri Blass »

stockfish with a single thread(32 bits) does not see a mate score

New game
1q1r3k/3P1pp1/ppBR1n1p/4Q2P/P4P2/8/5PK1/8 w - - 0 1

Analysis by Stockfish 1.5 JA:

1.Kg2-g3
± (1.37) Depth: 1 00:00:00
1.Kg2-g3 Nf6xh5+ 2.Kg3-h4
² (0.68) Depth: 2 00:00:00
1.Rd6-d1 Qb8xe5 2.f4xe5 Nf6xh5
± (1.33) Depth: 2 00:00:00
1.Rd6-d1 Qb8-a7 2.Qe5-e7
± (1.29) Depth: 3 00:00:00
1.Rd6-d1 Qb8-a7 2.Qe5-e7 Qa7-c7
± (1.29) Depth: 4 00:00:00
1.Rd6-d1 Qb8-a7 2.Qe5-e7 Qa7-c7 3.Kg2-h3 Nf6xh5
± (0.72) Depth: 5 00:00:00
1.Rd6-d3 Qb8-a7 2.Rd3-g3 Rd8xd7 3.Bc6xd7 Qa7-b7+ 4.Kg2-f1 Qb7xd7
± (0.92) Depth: 5 00:00:00
1.Rd6-d3 Qb8-a7 2.Rd3-g3 Rd8xd7 3.Bc6xd7 Qa7-b7+ 4.Kg2-f1 Qb7xd7
± (0.92) Depth: 6 00:00:00 10kN
1.Rd6-d3 Qb8-a7 2.Rd3-g3 Rd8xd7 3.Bc6xd7 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kg8-h8 4.Rd6xf6 g7xf6 5.Qe7xf6+ Kh8-g8 6.Qf6xh6 Rd8xd7 7.Qh6-g5+ Kg8-f8 8.Bc6xd7 Qc7xd7 9.h5-h6 Qd7-e6+ 10.Ke2-f1 Qe6-c4+ 11.Kf1-g2 Qc4-d4 12.Kg2-g3 b6-b5 13.a4xb5 Qd4-d3+ 14.Kg3-g4 a6xb5 15.Qg5-g7+ Kf8-e7
+- (1.77) Depth: 21 00:02:24 98201kN
1.Kg2-f3 Kh8-g8 2.Qe5-e7 Qb8-c7 3.Kf3-e2 Kg8-h8 4.Rd6xf6 g7xf6 5.Qe7xf6+ Kh8-g8 6.Qf6xh6 Rd8xd7 7.Qh6-g5+ Kg8-f8 8.Bc6xd7 Qc7xd7 9.h5-h6 Qd7-e6+ 10.Ke2-f1 Qe6-c4+ 11.Kf1-g2 Qc4-d4 12.Kg2-g3 Qd4-d3+ 13.f2-f3 Qd3-d4 14.Qg5-e5 Qd4-g1+ 15.Kg3-h4 Qg1-h1+ 16.Kh4-g5 Qh1xf3
+- (1.65) Depth: 22 00:04:13 170286kN
1.Kg2-f3 Kh8-g8 2.Qe5-e7 Qb8-c7 3.Kf3-e2 Kg8-h8 4.Ke2-f1 Kh8-g8 5.Kf1-g2 Kg8-h8 6.Rd6xf6 g7xf6 7.Qe7xf6+ Kh8-g8 8.Qf6xh6 Rd8xd7 9.Qh6-g5+ Kg8-f8 10.Bc6xd7 Qc7xd7 11.h5-h6 Qd7-d4 12.Kg2-g3 Qd4-c3+ 13.Kg3-h4 Qc3-d4 14.f2-f3 b6-b5 15.a4xb5 a6xb5 16.Qg5xb5 Qd4xf4+
+- (1.73) Depth: 23 00:11:26 464275kN

(so k, 07.10.2009)
Uri Blass
Posts: 10961
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Uri Blass »

Tord Romstad wrote:I can't reproduce this (which is not unexpected, as you were using two threads), but the general rule is that you can never trust the fail high scores reported by Stockfish, not even as lower bounds. You have to wait until the fail high is resolved, usually at the next iteration. Perhaps we should just display the upper boundary of the window instead of the score returned by the search when a fail high at the root occurs.

Joona's aspiration window search is highly unorthodox and frequently displays weird behavior. The only reason I like it is that it works incredibly well when playing games. :)

By the way, Stockfish 1.5 is no different from 1.4 in this respect.
I wonder if it is not better to have a more realistic score.
You can have a function that translates fail high score and previous score to more realistic score and decide that the more realistic score is the score of the move.

If I understand correctly
The situation today is that stockfish may miss some good winning move that is not mate at depth 21 because it found some wrong mate in 12 score and it may need depth 22 for it.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Stockfish-1.5 Detects mate then changes mind?

Post by zamar »

I'm not sure that aspiration window is the guilty one in here.

When we have aspiration fail high with mate score, one played move (in this case Kf3) returned _mate_ score. This should never happen (even in fail highs) if there is no mate.

You definetily should be able to trust the upper/lower bound returned by aspiration search. So there _is_ a bug. Unfortunately I'm not able to reproduce it either.
Joona Kiiski
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Tord Romstad »

Uri Blass wrote:If I understand correctly
The situation today is that stockfish may miss some good winning move that is not mate at depth 21 because it found some wrong mate in 12 score and it may need depth 22 for it.
Actually, when a new best move is found and the score is above the aspiration window, Stockfish doesn't try to resolve the fail high, but skips all the remaining moves at the current iteration, and starts searching the new best move at the next iteration. This is very radical, and seems so crazy that it obviously can't work. One of Joona's unique skills is coming up with such outrageous ideas, being brave enough to actually spend time implementing and testing them, and proving that they are tremendously effective in practice.
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Tord Romstad »

zamar wrote:I'm not sure that aspiration window is the guilty one in here.

When we have aspiration fail high with mate score, one played move (in this case Kf3) returned _mate_ score. This should never happen (even in fail highs) if there is no mate.

You definetily should be able to trust the upper/lower bound returned by aspiration search. So there _is_ a bug. Unfortunately I'm not able to reproduce it either.
It shouldn't be that hard to find a reproducible example, I think. I have seen this happen numerous times. I'll have a look right now and see if I find something (but it's probably better to discuss by e-mail rather than making noise here on the CCC).
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Stockfish-1.5 Detects mate then changes mind?

Post by zamar »

Tord Romstad wrote: Joona's aspiration window search is highly unorthodox and frequently displays weird behavior. The only reason I like it is that it works incredibly well when playing games. :)
Do you have an example (preferably reproducible :)) of such a weird behaviour? I want to underline that you must be able to trust the score (upper/lowerbound) returned by aspiration search. Any other behaviour I consider a serious bug.
Joona Kiiski
Uri Blass
Posts: 10961
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Uri Blass »

Tord Romstad wrote:
zamar wrote:I'm not sure that aspiration window is the guilty one in here.

When we have aspiration fail high with mate score, one played move (in this case Kf3) returned _mate_ score. This should never happen (even in fail highs) if there is no mate.

You definetily should be able to trust the upper/lower bound returned by aspiration search. So there _is_ a bug. Unfortunately I'm not able to reproduce it either.
It shouldn't be that hard to find a reproducible example, I think. I have seen this happen numerous times. I'll have a look right now and see if I find something (but it's probably better to discuss by e-mail rather than making noise here on the CCC).
I think that this discussion is interesting and I see no problem with the noise here.

Other programmers may also learn things from the noise.
Maybe it is better to do it in the programming section and not in the general topics.

Uri
Uri Blass
Posts: 10961
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Stockfish-1.5 Detects mate then changes mind?

Post by Uri Blass »

Tord Romstad wrote:
Uri Blass wrote:If I understand correctly
The situation today is that stockfish may miss some good winning move that is not mate at depth 21 because it found some wrong mate in 12 score and it may need depth 22 for it.
Actually, when a new best move is found and the score is above the aspiration window, Stockfish doesn't try to resolve the fail high, but skips all the remaining moves at the current iteration, and starts searching the new best move at the next iteration. This is very radical, and seems so crazy that it obviously can't work. One of Joona's unique skills is coming up with such outrageous ideas, being brave enough to actually spend time implementing and testing them, and proving that they are tremendously effective in practice.

I wonder if you tried instead of skipping the rest of the moves to make a research with bigger depth after fail high(like you do after fail high in case of late move reductions)

There is going to be no difference in the score of the move that fail high but the rest of the moves are going to be searched with smaller depth.

In the next iteration you can simply skip the first move.

Note that skipping the first move in case that the branching factor was high in the last iteration may be also an interesting idea to try.
Here is an example from analysis by rybka.
The branching factor was very high at depth 24 because rybka needed a long time to get a score for Bd1 and rybka immediately get a score at depth 25 with the same pv so it seems simply to skip Bd1 at depth 25(this is from analysis of one of my correspondence games and I do not give the position and the pv).

23 2:06:44 690.267.702 92.954 +0.49 Be2d1
24 11:25:14 3.953.564,204 98.462 +0.52 Be2d1

25 11:25:14 3.953.564,224 98.462 +0.52 Be2d1

Uri