Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go mate x in multithreading #5094

Closed
wants to merge 1 commit into from
Closed

Fix go mate x in multithreading #5094

wants to merge 1 commit into from

Conversation

peregrineshahin
Copy link
Contributor

@peregrineshahin peregrineshahin commented Mar 7, 2024

Fixes two issues with master for go mate x:

  • when running go mate x in losing positions, master always goes to the maximal depth, arguably against what the UCI protocol demands
  • when running go mate x in winning positions with multiple threads, master may return non-mate scores from the search (this issue is present in stockfish since at least sf16) The issues are fixed by (a) also checking if score is mate -x and by (b) only letting mainthread stop the search for go mate x commands, and by not looking for a best thread but using mainthread as per the default.

Related: niklasf/python-chess#1070

More diagnostics can be found here https://github.com/peregrineshahin/Stockfish/pull/6#issuecomment-1983100667

No functional change.

Fixes two issues with master for go mate x:

when running go mate x in losing positions, master always goes to the maximal depth, arguably against what the UCI protocol demands
when running go mate x in winning positions with multiple threads, master may return non-mate scores from the search (this issue is present in stockfish since at least sf16) The issues are fixed by (a) also checking if score is mate -x and by (b) only letting mainthread stop the search for go mate x commands, and by not looking for a best thread but using mainthread as per the default.
Related: niklasf/python-chess#1070

More diagnostics can be found here peregrineshahin#6 (comment)

No functional change.

Co-Authored-By: Robert Nürnberg <28635489+robertnurnberg@users.noreply.github.com>
@peregrineshahin
Copy link
Contributor Author

@robertnurnberg I just found out that this effectively reverts this commit, but other the fixes are not trivial...
d5f883a

@robertnurnberg
Copy link
Contributor

robertnurnberg commented Mar 7, 2024

Noted. I think it is best to merge this PR as an urgent fix as it is.

Improving mate finding for go mate x commands in multithreading mode can then be left for the future. It won't be easy to generalize @vondele 's old patch to the new best thread selection algorithm.

@Disservin Disservin added the to be merged Will be merged shortly label Mar 7, 2024
@Disservin Disservin closed this in 748791f Mar 7, 2024
Disservin pushed a commit that referenced this pull request Mar 7, 2024
Fixes an oversight in #5094

In theory, master could stop search when run with `go mate 247` and return a TB loss (not a mate score). Also fixes the spelling of opponenWorsening.

closes #5096

No functional change
@robertnurnberg
Copy link
Contributor

Just for completeness, running the testing script from https://github.com/peregrineshahin/Stockfish/pull/6#issuecomment-1983100667 with more threads and up to go mate 16 positions also did not result in any errors for this patch:

Running ./stockfish with 8 threads and 1024MB hash, up to 'go mate 16'.
run    10: error count = 0, short count = 0, maxdepth count = 0.
<snip>
run  1990: error count = 0, short count = 0, maxdepth count = 0.
run  2000: error count = 0, short count = 0, maxdepth count = 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to be merged Will be merged shortly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants