Fail-High / Fail-Low in mate situations...

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28468
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Fail-High / Fail-Low in mate situations...

Post by hgm »

Steve Maughan wrote:Note I do not do hash cutoffs at PV_NODES.
Ah, so that is the inconsistency then.

Then you just see here how not doing cutoffs at PV nodes hurts you. You fail to profit from the extra depth you could have had by hitting upon an overdeep hash entry.

There are also other ways search instability can occur, so you should always be prepared for the re-search of a fail high to fail low.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Fail-High / Fail-Low in mate situations...

Post by xmas79 »

Please give a try with 8mb tt size and with 1gb tt size.I bet you'll get different results.Also be sure you have a complete pv to the mate.i now store pv in another place instead of tt and i'm fully able to retrieve it. That gave more different (and better) results. I didnt tested my original position as i'm out.more on monday. But i'm absolutely sure this is perfectly normal,and has everything to do with the luck of overwriting the wrong/right entry in the tt.pv on another place helps aearch instability issues.

Natale
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Fail-High / Fail-Low in mate situations...

Post by xmas79 »

Maybe it is an inconsistency,but in this case the CUT offs occur on fail high part of the tt probe.I disabled CUT offs in exact entries completely and the instabity never went away.only when removing CUT offs on the fail high part
JVMerlino
Posts: 1407
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Fail-High / Fail-Low in mate situations...

Post by JVMerlino »

Seems to work fine (although very slow compared to a decent engine).

[d]5n2/B3K3/2pN2p1/3k4/6NP/3b2P1/2P1n1P1/1q6 w - - 0 16

Code: Select all

17   562   1606  18441132 c2c4! d5e5 (1147 KNPS)
17   576   1711  19706741 c2c4 d3c4 g4e3 d5e5 e3c4 e5d5 c4e3 d5e5 d6c4 e5e4 c4d2
 e4d3 d2b1 f8h7 e7f7 e2g3 f7g7 g6g5 g7h7 g5h4 b1a3 g3e4 a3c4 c6c5 h7g6 (1151 KNP
S)
18   564   2073  24112931 c2c4 d3c4 g4e3 d5e5 e3c4 e5d5 c4e3 d5e5 d6c4 e5e4 c4d2
 e4d3 d2b1 f8h7 e7f7 e2g3 f7g7 g6g5 g7h7 g5h4 b1a3 g3e4 a3c4 c6c5 a7b6 e4d2 c4d2
 d3e3 (1163 KNPS)
19   575   3519  39545412 c2c4 d3c4 g4e3 d5e5 e3c4 e5d5 c4e3 d5e5 d6c4 e5e4 c4d2
 e4d3 d2b1 f8h7 e7f7 e2g3 f7g7 g6g5 g7h7 g5h4 b1a3 g3e4 a3c4 c6c5 a7b6 e4d2 c4d2
 d3e3 d2f3 (1123 KNPS)
20   586   6116  67647038 c2c4 d3c4 g4e3 d5e5 e3c4 e5d5 c4e3 d5e5 d6c4 e5e4 c4d2
 e4d3 d2b1 f8h7 e7f7 e2g3 f7g7 g6g5 g7h7 g5h4 b1a3 g3e4 a3c4 c6c5 a7b6 e4f6 h7g6
 f6e4 b6c7 d3d4 (1105 KNPS)
21   614   9297 105750444 c2c4 d3c4 g4e3 d5e5 e3c4 e5d5 c4e3 d5e5 d6c4 e5e4 c4d2
 e4d3 d2b1 f8h7 e7f7 e2g3 f7g7 g6g5 g7h7 g5h4 b1a3 g3e4 a3c4 c6c5 a7b6 e4f6 h7g6
 f6e4 b6c7 e4c3 c7e5 (1137 KNPS)
21   626  10648 122270085 g4f6! d5e5 (1148 KNPS)
21   736  10650 122270115 g4f6! (1148 KNPS)
21 32738  10664 122467033 g4f6 d5e5 d6f7 e5f5 f7h6 f5e5 h6g4 e5f5 g4e3 f5e5 f6g4
 e5e4 g4f2 e4e5 f2d3 e5e4 d3f2 e4e5 f2g4 e5e4 g4f6 e4e5 e3c4 e5f5 c4d6 f5e5 f6g4
 e5d5 c2c4 (1148 KNPS)
22 32738  11335 131027769 g4f6 d5e5 d6f7 e5f5 f7h6 f5e5 h6g4 e5f5 g4e3 f5e5 f6g4
 e5e4 g4f2 e4e5 f2d3 e5e4 d3f2 e4e5 f2g4 e5e4 g4f6 e4e5 e3c4 e5f5 c4d6 f5e5 f6g4
 e5d5 c2c4 (1155 KNPS)
23 32738  13252 154889023 g4f6 d5e5 d6f7 e5f5 f7h6 f5e5 h6g4 e5f5 g4e3 f5e5 f6g4
 e5e4 g4f2 e4e5 f2d3 e5e4 d3f2 e4e5 f2g4 e5e4 g4f6 e4e5 e3c4 e5f5 c4d6 f5e5 f6g4
 e5d5 c2c4 (1168 KNPS)
24 32738  17484 208728295 g4f6 d5e5 d6f7 e5f5 f7h6 f5e5 h6g4 e5f5 g4e3 f5e5 f6g4
 e5e4 g4f2 e4e5 f2d3 e5e4 d3f2 e4e5 f2g4 e5e4 g4f6 e4e5 e3c4 e5f5 c4d6 f5e5 f6g4
 e5d5 c2c4 (1193 KNPS)
g4f6
 1 32739      0        61 d5e5 d6f7 e5f5
 2 32739      0        98 d5e5 d6f7 e5f5
 3 32739      1       135 d5e5 d6f7 e5f5 (8 KNPS)
 4 32739      1       172 d5e5 d6f7 e5f5 (10 KNPS)
 5 32739      1       211 d5e5 d6f7 e5f5 (13 KNPS)
 6 32739      3       287 d5e5 d6f7 e5f5 (8 KNPS)
 7 32739      3       363 d5e5 d6f7 e5f5 (11 KNPS)
 8 32739      4       443 d5e5 d6f7 e5f5 (9 KNPS)
 9 32739      4       582 d5e5 d6f7 e5f5 (12 KNPS)
10 32739      4       663 d5e5 d6f7 e5f5 (14 KNPS)
11 32739      4       780 d5e5 d6f7 e5f5 (16 KNPS)
12 32739      6      1204 d5e5 d6f7 e5f5 (19 KNPS)
13 32739      6      1656 d5e5 d6f7 e5f5 (26 KNPS)
14 32739      6      2184 d5e5 d6f7 e5f5 (34 KNPS)
15 32739      7      2995 d5e5 d6f7 e5f5 (38 KNPS)
16 32739      7      4093 d5e5 d6f7 e5f5 (52 KNPS)
17 32739      7      5954 d5e5 d6f7 e5f5 (76 KNPS)
18 32739      9      9095 d5e5 d6f7 e5f5 (96 KNPS)
19 32739      9     15222 d5e5 d6f7 e5f5 (161 KNPS)
20 32739     11     38744 d5e5 d6f7 e5f5 (352 KNPS)
21 32739     15     89824 d5e5 d6f7 e5f5 (575 KNPS)
22 32739     21    190438 d5e5 d6f7 e5f5 (869 KNPS)
23 32739     46    512601 d5e5 d6f7 e5f5 (1095 KNPS)
d5e5
 1 32740      0         3 d6f7 e5f5
 2 32740      1        41 d6f7 e5f5 (2 KNPS)
 3 32740      1        79 d6f7 e5f5 (4 KNPS)
 4 32740      1       117 d6f7 e5f5 (7 KNPS)
 5 32740      3       155 d6f7 e5f5 (5 KNPS)
 6 32740      3       239 d6f7 e5f5 (7 KNPS)
 7 32740      3       605 d6f7 e5f5 (19 KNPS)
 8 32740      4       964 d6f7 e5f5 (20 KNPS)
 9 32740      4      1329 d6f7 e5f5 (28 KNPS)
10 32740      4      1911 d6f7 e5f5 (40 KNPS)
11 32740      6      2190 d6f7 e5f5 (34 KNPS)
12 32740      6      2649 d6f7 e5f5 (42 KNPS)
13 32740      6      3114 d6f7 e5f5 (49 KNPS)
14 32740      6      3623 d6f7 e5f5 (57 KNPS)
15 32740      7      4461 d6f7 e5f5 (57 KNPS)
16 32740      7      5348 d6f7 e5f5 (68 KNPS)
17 32740      7      6622 d6f7 e5f5 (84 KNPS)
18 32740     21     78585 d6f7 e5f5 (358 KNPS)
19 32740     34    215324 d6f7 e5f5 (627 KNPS)
20 32740     57    435343 d6f7 e5f5 (754 KNPS)
21 32740     88    799556 d6f7 e5f5 (899 KNPS)
22 32740    146   1468259 d6f7 e5f5 (1000 KNPS)
23 32740    433   4612497 d6f7 e5f5 (1063 KNPS)
24 32740    872   9667729 d6f7 e5f5 (1108 KNPS)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Fail-High / Fail-Low in mate situations...

Post by bob »

What could you possibly do? You have a deep draft tt entry that says mate in no more than X. But it is a bound. You can't search deeply enough to resolve the mate, so you get a non-mate score. There's nothing that can be done, unless you want to disallow the bound causing a cutoff. May as well throw the TT out then...
User avatar
hgm
Posts: 28468
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Fail-High / Fail-Low in mate situations...

Post by hgm »

Actually there are things you can do. If the problem is that the TT entry with the mate score is just a lower bound, so that it is no good for a hash cutof in a PV node even if you do allow those, you could make an exception for mate scores. Mate scores are usually reliable bounds; if a search turns up a mate score as lower bound it really must have seen a way to force a mate in the reported number of moves. These are not things that could be imagined due to prunings that are only allowed with null-windows etc. The only issue is that there could be a faster mate.

So if your TT gives you a mate-score as lower bound, but you need an exact score, so you re-search, and the re-search cannot find a mate, you would do better to return the TT bound than to return the score from the re-search. The error in this score will surely be far smaller than when you would return a non-mate score.

This also holds when you do not allow hash cuts in PV nodes and have an exact entry. You do the search there mainly as a kludge to recover the PV from the TT, and the fact that this might replace the score from over-deep hits by the less-reliable score from the search at nominal depth is an unwanted side effect. In case of a mate score you could decide to use the TT score anyway, after you searched the move at nominal depth to recover the PV. Normally there would be an entire trail of entries leading to the mate in the TT, so in fact only the first miss would return a non-mate score, which in its parent would be overruled by the TT mate score obtained at higer depth. And from there it would propagate in the normal way to the root.
Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Re: Fail-High / Fail-Low in mate situations...

Post by Karlo Bala »

Steve Maughan wrote:Maverick has a problem.

It's illustrated in the diagram below. In this case Maverick has found a mate in 14 from a previous search. So when it starts searching Nf7 fails high on the first few ply due to the stored value in the hash table. When the search window is increased Maverick must find the mate, which it doesn't due to lack of depth. So it fails low. This results in the nasty fail-high followed by fail-low pattern. I know it's not a big issue but is there any way to stop this?

Thanks,

Steve
Image
It is common if you use singular extensions based on windows around the score. After changing the score to the checkmated score, SE is not triggered because every move fall inside the window.
Best Regards,
Karlo Balla Jr.
User avatar
Steve Maughan
Posts: 1317
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Fail-High / Fail-Low in mate situations...

Post by Steve Maughan »

Hi H.G,

I took your advice and added hash cutoffs to PV nodes. If the score is exact and falls between alpha and beta I fill the PV with the moves from the hash table. It works well (and doesn't look ugly).

Thanks,

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Fail-High / Fail-Low in mate situations...

Post by xmas79 »

Hi Steve,
allowing hash cutoffs in PV nodes will never solve your instability. Your instability will only "change". I'm absolutely sure these kind of things are pretty common and normal.

The fact is that the "normal" behaviour is to NOT see mate before the nominal depth. BUT, engine will see mate scores before nominal search depth because it will get hash hits all over the tree during search saying "mate in 3", "mate in 4", "mated in 7" etc... and these hash entries are ALL lower/upper bounds types scores. So your engine has the ability to cut-off on non-PV nodes, but it cannot take any kind of cut in PV nodes, as the score required is EXACT, and in your hashtable there is no single entry that says "hey that's a mate in 16 moves, and that's an exact score!", as this would be the mate you're searching for!!
I told you to be sure you have a PV to the mate, as if you don't (and you don't), your engine will research on a window that is (alpha,+INF), and all the cut-offs "available" when searching with a window that is (alpha, +INF-1000 lets say) are no more profitable, so engine relies only on its search capabilities, and as it has no the "right" depth, will fail to see the mate and report the best score it can see with the search only - a draw.

Natale.
User avatar
Steve Maughan
Posts: 1317
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Fail-High / Fail-Low in mate situations...

Post by Steve Maughan »

Hi Natale,

I actually do have an EXACT mate score in the hash. This is the PV from the previous search. It makes sense to use this information. So now what I do is to take the PV node cutoff and fill the PV with info from the hash table. It seems to work well.

Best regards,

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine