Chessnut1071 wrote: ↑Thu Sep 15, 2022 4:42 amhow long did it take your engine to prove there was no 9-move mate? My engine took an embarrassing 7:58:01 [hh/mm/ss] checking every possible move. If your engine found that in under an hour, I'd like to know how you did it.
My CT800 engine has a dedicated mate solver with some tricks to find a mate if there is one - but if there is none, it amounts to full search with alpha-beta reduction only, i.e. no unsafe pruning. For "go mate 9", it took ~19 minutes (single threaded on Ryzen 5700G) to show that there is no mate in 9:
Code: Select all
info depth 17 seldepth 17 score cp 0 time 1115307 nodes 1417257052 nps 1270732
info string error (no mate found)
bestmove 0000
With "go mate 10", showing that there is no mate in 10 either, it took 10:40 hours:
Code: Select all
info depth 19 seldepth 19 score cp 0 time 38431488 nodes 53708569986 nps 1397514
info string error (no mate found)
bestmove 0000
The trick is modified move sorting: rank checks highest, then MVV/LVA, then history. Also, drop any move that does not deliver check in the last depth level because without check, it cannot be a checkmate. Any end position without check (or with check, but no checkmate) is scored as draw because homogenous scores help with beta-pruning, and hash tables are used only for such draw positions (which is nearly every position).
For positions that do have a solution, there is another trick: restrict the moves of the attacking side to check-giving moves because mate problems often involve a series of checks. First in all depth levels, then non-checks at exactly one depth level (iterating that through all depth levels), and then increasing from the deepest level onwards. Means, allow non-checks in the last-but one and the one before, then also in the level before that, and so on. The defending side ofc always has all moves.
What takes long if there is no solution is the last iteration with all moves for both sides except the last depth level of the attacking side that must be a check.