Testing the Search Function

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Testing the Search Function

Post by xmas79 »

Stan Arts wrote:...
Respectively mate in 28, 27, 24, 22, 21, 20, 19, 18, 17, 17, 17 and finally 16 is found which I suppose is the correct solution. Robert Hyatt gets a point because I must admit my hash pv's are pretty crappy here. :?
There's always an engine crapper than yours:

Code: Select all

 00:00:10.657   29     Rg2-g5!!     4.2M  +MATE15        1. Rg2-g5    Kf3-f4
                                                         2. Rg5-a5    Kf4-e4
                                                         3. Kh1-g2    Ke4-d4
                                                         4. Ra5-h5    Kd4-e3
                                                         5. Rh5-f5    Ke3-e4
                                                         6. Rf5-c5    Ke4-d4
                                                         7. Rc5-h5    Kd4-c4
                                                         8. Rh5-g5    Kc4-c3
                                                         9. Kg2-f2    Kc3-b3
                                                        10. Rg5-g4    Kb3-b2
                                                        11. Kf2-g1    Kb2-c2
                                                        12. Kg1-f2    Kc2-d3
                                                        13. Kf2-f3    Kd3-c3
                                                        14. Kf3-e2    Kc3-c2
                                                        15. Rg4-c4+   Kc2-b3
                                                        16. Ke2-d3    Kb3-b2
                                                        17. Rc4-c3    Kb2-b1
                                                        18. Rc3-b3+   Kb1-a1
                                                        19. Kd3-c2    Ka1-a2
                                                        20. Rb3-c3    Ka2-a1
                                                        21. Rc3-a3#
Mate in 15 and the PV is 21 moves long??? Crappy software I wrote.... The only excuse I have is that the engine is in an heavy rewrite stage, so I have broke it badly... Go figure what's wrong with that...

Well, at least mate in 15 shoud be correct...
Uri Blass
Posts: 10279
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Testing the Search Function

Post by Uri Blass »

xmas79 wrote:
Stan Arts wrote:...
Respectively mate in 28, 27, 24, 22, 21, 20, 19, 18, 17, 17, 17 and finally 16 is found which I suppose is the correct solution. Robert Hyatt gets a point because I must admit my hash pv's are pretty crappy here. :?
There's always an engine crapper than yours:

Code: Select all

 00:00:10.657   29     Rg2-g5!!     4.2M  +MATE15        1. Rg2-g5    Kf3-f4
                                                         2. Rg5-a5    Kf4-e4
                                                         3. Kh1-g2    Ke4-d4
                                                         4. Ra5-h5    Kd4-e3
                                                         5. Rh5-f5    Ke3-e4
                                                         6. Rf5-c5    Ke4-d4
                                                         7. Rc5-h5    Kd4-c4
                                                         8. Rh5-g5    Kc4-c3
                                                         9. Kg2-f2    Kc3-b3
                                                        10. Rg5-g4    Kb3-b2
                                                        11. Kf2-g1    Kb2-c2
                                                        12. Kg1-f2    Kc2-d3
                                                        13. Kf2-f3    Kd3-c3
                                                        14. Kf3-e2    Kc3-c2
                                                        15. Rg4-c4+   Kc2-b3
                                                        16. Ke2-d3    Kb3-b2
                                                        17. Rc4-c3    Kb2-b1
                                                        18. Rc3-b3+   Kb1-a1
                                                        19. Kd3-c2    Ka1-a2
                                                        20. Rb3-c3    Ka2-a1
                                                        21. Rc3-a3#
Mate in 15 and the PV is 21 moves long??? Crappy software I wrote.... The only excuse I have is that the engine is in an heavy rewrite stage, so I have broke it badly... Go figure what's wrong with that...

Well, at least mate in 15 shoud be correct...
Tablebases say mate in 16 and not 15.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Testing the Search Function

Post by xmas79 »

Uri Blass wrote:Tablebases say mate in 16 and not 15.
Crappy... Veeeery crappy... So I have something to worry about....
User avatar
Fabio Gobbato
Posts: 217
Joined: Fri Apr 11, 2014 10:45 am
Full name: Fabio Gobbato

Re: Testing the Search Function

Post by Fabio Gobbato »

I bring the search function, I remove all the pruning and instead of calling the qsearch I generate a random number and I trasform in a Perft.
In this way I can check the move ordering, that every move would played one single time and no move would skipped.
I can check hash, killer and history and I debug the pruning function later.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Testing the Search Function

Post by bob »

Uri Blass wrote:
bob wrote:
PK wrote:Most programs have incorrect search. TSCP has correct one, but its strength is about 1700 Elo. Techniques that can bring a program from 1700 to 3200 Elo progressively introduce more and more incorrectness. The real trick is to use these techniques in such a way that all their errors are hidden.

Having said that, there are things that a search has to do correctly. Beside things that You mentioned (repetitions, draw by 50 move rule), many search bugs can be detected by looking at simple endgames. If a program doesn't checkmate with K+R vs K, it's obviously broken. If it cannot see a simple win like 8/1k3ppp/8/5PPP/K7/8/8/8 w - - 0 1 it has a problem. If it gets these two right, harder stuff can be found in endgame manuals. In general endgames are good for exposing search errors.
Your examples are not very good. whether you can mate with K+R vs K is not always a search issue. And playing any type of game where evaluation is involved hides search issues.

Best way to debug is to run a few positions to a fairly minimal depth (say 6 plies) and dump the search tree. Then check what is searched in what order (hash move, which captures, killers, etc. See what was reduced or extended or pruned. Etc.
[D]8/8/8/8/8/5k2/6R1/7K w - - 0 1

I think that even with no evaluation today programs should search deep enough to see the shortest mate in KR vs K so if your program does not see the shortest mate in less than a minute or see forced mate but cannot win then it clearly has a problem in the search that you need to fix.

Stockfish(3 cores) without tablebases see mate in 16 in few seconds.
Senpai(3 cores) needs more time but still see mate in 16 after 25 seconds without using a fast computer.
The problem is that produces a very large tree. Which is NOT the kind of tree you want to debug with. For example, suppose you can not find the mate in 16, but can only see a mate in 17. How do you debug that with tens of millions of lines of output if you dump the tree?

My point was that there are some simple positions that can be used to track down these sorts of bugs MUCH easier than using positions that tend to produce enormous trees. I've been debugging a Hsu-like singular extension test and I ran WAC against the SE version to find the smallest tree where SE would kick in. Then I could dump the tree to a file, and look at what was going on to see if I like what I see or not. In a big tree, this is hopeless.