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

do not change cursed wins to draws (take 2) #5814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robertnurnberg
Copy link
Contributor

This PR is an improvement upon #5805.

It fixes a bug each in #5414 and 4c4e104.

The problem in each case is that is_draw() has no knowledge of the UCI option Syzygy50MoveRule, and so its calls have to be guarded.

An example position where the bug triggers is 7b/8/6b1/8/5Nk1/4K3/8/8 b - - 0 1. I.e. master shows an evaluation of cp 0, while the patch correctly shows cp 20000.

This PR also leads to correct PV extensions for cursed wins. Below the output of the corresponding matetrack check using the new matecheck.py script and the FEN collection cursed.epd from vondele/matetrack#130.

> python matecheck.py --epdFile cursed.epd --engine ../stockfish/src/patch --nodes 1000 --syzygyPath /disk1/syzygy/3-4-5-6/WDL:/disk2/syzygy/3-4-5-6/DTZ --syzygy50MoveRule false
Loaded 30 FENs, with max(|bm|) = 1.

Matetrack started for ../stockfish/src/patch on cursed.epd with --nodes 1000 --syzygyPath /disk1/syzygy/3-4-5-6/WDL:/disk2/syzygy/3-4-5-6/DTZ --syzygy50MoveRule false ...
100%|###########################################| 30/30 [00:03<00:00,  9.56it/s]

Found 510 tablebases. Checking 33 TB win PVs. This may take some time ...

Using ../stockfish/src/patch on cursed.epd with --nodes 1000 --syzygyPath /disk1/syzygy/3-4-5-6/WDL:/disk2/syzygy/3-4-5-6/DTZ --syzygy50MoveRule false
Engine ID:     Stockfish dev-20250121-4e5ae2be
Total FENs:    30
Found mates:   0
Best mates:    0
Found TB wins: 30

No functional change.

Copy link

clang-format 18 needs to be run on this PR.
If you do not have clang-format installed, the maintainer will run it when merging.
For the exact version please see https://packages.ubuntu.com/noble/clang-format-18.

(execution 12891593473 / attempt 1)

@robertnurnberg
Copy link
Contributor Author

A review by @vondele and @joergoster would be nice. And maybe @Torom could check if #3542 is handled correctly in the absence of the 50 move rule.

By the way, it seems to me that the bug in 4c4e104 could have led to incorrect game play without 50mr. By assigning a dtz and rank of 0 to all winning TB moves once the root position returns is_draw(1) as true due to more than 50 moves since the last capture or pawn move.

@vondele
Copy link
Member

vondele commented Jan 21, 2025

Thanks!
Have you checked the testcase in #3542 still is handled correctly?

@robertnurnberg
Copy link
Contributor Author

Thanks! Have you checked the testcase in #3542 still is handled correctly?

I think our two comment crossed. :) In the case of 50mr the patch is non-functional, and so #3542 should not be affected. But I have asked @Torom to check if it is also solved without 50mr. I believe it should, because 3-folds are handled exactly as in master.

@Torom
Copy link
Contributor

Torom commented Jan 21, 2025

I can confirm that nothing has changed in the behavior for the case from #3542.
The relevant move is evaluated both in master and in the patch with Syzygy50MoveRule true as well as false as cp 0.

@vondele
Copy link
Member

vondele commented Jan 21, 2025

I think this makes sense, maybe @joergoster has a comment on this one.

@joergoster
Copy link
Contributor

Looks good to me.

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

Successfully merging this pull request may close these issues.

4 participants