mcostalba wrote:Someone asked me for supporting UCI command 'go mate x' that finds the checkmate variation in a given position.
I looked at Fruit/Toga sources that seem the only open sources I know to support the feature, but there I saw they simply fall back on a search at fixed depth x, so nothing fancy here.
So I implemented a bit smarter algorithm (but IMO still well improvable):
https://github.com/mcostalba/Stockfish/ ... f486a5ea80
Here the trick is to return from a PV node if we are already above the 'x' moves limits. It means we still don't have found the mate so there is no need to continue the search. Note that non-PV search is not affected (also because I don't want to slow down the search with this toy feature, so I can afford an extra check in PV, but don't want _any_ slowdown in non-PV case).
Someone has/knows a better approach ?
P.S: It should be light, non-intrusive and easy to implement.

Hello Marco,
sitting here and drinking my first coffee in the morning to wake up
and reading your post i just have an idea never tested or seen somewhere. Maybe it is nonsense, but anyway.
The first thing i would try without changing the search would be to
modify the root's alpha beta window. I dont think we need to
search lbound to ubound or sth. like that. If we are in mate-search
mode we only need to test for mateIn(d) score. if that fails we continue
with the next depth, until we find a depth having a mate.
The first advantage i see is that in a mate search we only have to set
the root window different, which keeps the code clean. The second
point is that it should find existing mates (much) faster than the normal
search.
I think that would be the first step, if i would setup the feature. Further
code improvements would be a matter of how important this feature
is to me.
Happy new year to you and everyone here.
Michael