hyatt wrote:My point was not that you needed the - 1 or + 1, but that you have to carefully look. For example, why not do this:
when you store a mate score, display the tree and print the actual score and the stored score. When you hit on a position with a mate score, display the position, the table score, and the adjusted mate score. You should quickly see what is going wrong.
You could use a simple mate in 3, searched just deeply enough to see it. Then make the expected move and see what kind of table scores you get back (which ought to be mate in 2). That will be a tiny amount of output with the displays I recommended above.
Thanks for the the tip. I tested a simple mate in two K vs KR and immediately found a problem. I noticed that I was storing mate values in the table for positions that didn't have mate (for example king vs king). Later I found that sometimes the best score passed to the store function was incorrect. After fixing this and adjusting correctly the mate scores everything worked for many test positions, except one thing.. sometimes the principal variation had illegal moves. For example for the first test position I get this output:
- Code: Select all
info depth 1 score cp 500 nodes 30 nps 29999 time 1 pv b3a3
info depth 2 score cp 600 nodes 255 nps 7727 time 33 pv b3a3 d8c8
info depth 3 score cp 600 nodes 1269 nps 30951 time 41 pv b3a3 d8c8 b7f7
info depth 4 score cp 700 nodes 6492 nps 150976 time 43 pv b3a3 d8c8 b7f7 c8b8
info depth 5 score cp 700 nodes 27997 nps 538403 time 52 pv b3a3 d8c8 b7f7 c8b8 a3a2
info depth 6 score cp 700 nodes 108269 nps 1244471 time 87 pv b3a3 d8c8 b7f7 c8b8 a3a2 b8c8
info depth 7 score cp 700 nodes 417761 nps 1952154 time 214 pv b3a3 d8c8 b7f7 c8b8 a3a2 c6c5 f7f3
info depth 8 score cp 800 nodes 1776687 nps 2400928 time 740 pv b3a3 d8c8 b7f7 c8b8 a3a2 c6c5 f7f6 b8b7
info depth 9 score mate 6 nodes 6722469 nps 2523449 time 2664 pv b3a3 d8c8 b7f7 a2a1r a3a1 c8b8 a1a2 c6c5 a3a8 c8b7 a3a2
info depth 10 score mate 6 nodes 24682574 nps 2597071 time 9504 pv b3a3 d8c8 b7f7 a2a1r a3a1 c8b8 e1f2 c6c5 a1e1 b8a8 e1e8
info depth 11 score mate 6 nodes 85643666 nps 2590395 time 33062 pv b3a3 d8c8 b7f7 a2a1r a3a1 c8b8 e1f2 c6c5 a1e1 b8a8 e1e8
The pv for depth 9 (the first time it finds mate) has a strange sequence "a1a2 c6c5 a3a8 c8b7 a3a2" with illegal moves. I'm not sure why this happens but I have to investigate it more. If I don't find a solution, I'll open a new post if needed.
Thank you again!