Turning off 50-move draw rule in Stockfish & other engines

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
MikeB
Posts: 3939
Joined: Thu Mar 09, 2006 5:34 am
Location: Pen Argyl, Pennsylvania

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by MikeB » Sun Mar 15, 2020 10:54 pm

jp wrote:
Sun Mar 15, 2020 10:33 pm
Joerg Oster wrote:
Sun Mar 15, 2020 9:35 pm
You might give Moonfish a try. https://github.com/joergoster/Moonfish

If you set "Syzygy50MoveRule" to false, this will also switch it off for the search.
MikeB wrote:
Sun Mar 15, 2020 9:57 pm
Stockfish , as do many engines, have a checkbox to turnoff 50 move rule enforcement.
...
option name Syzygy50MoveRule type check default true
...

If you using stockfish under GUI, the GUI also must be able to turn the 50 move off ( usually, since most GUIs on by default). Older versions of Winboard/xBoard, which use polyglot, must also use a hacked version of Polyglot since polyglot also enforces the 50 move rule, which I have if you need it.
Can you clarify?

Descriptions of Syzygy50MoveRule are like this:
Syzygy50MoveRule
Disable to let fifty-move rule draws detected by Syzygy tablebase probes count as wins or losses. This is useful for ICCF correspondence games.
Does it turn off all 50-move rule enforcement, even if no Syzygy tablebases (no tablebases of any sort) are used (or it's far from any TB position)? That's what's wanted.
It is triggered by tablebase mode - you specifically mentioned cursed wins - that definition came from the creation of tablebases. I suggest you would not want to turn off 50 move rule when you're not in TB mode. You will have games that may never end. It works fine if you are interested in the cursed wins arising from TB which is what I thought you wanted. If you are looking for more than that , I cant really help you easily.

jp
Posts: 1328
Joined: Mon Apr 23, 2018 5:54 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by jp » Sun Mar 15, 2020 10:59 pm

MikeB wrote:
Sun Mar 15, 2020 10:54 pm
It is triggered by tablebase mode - you specifically mentioned cursed wins - that definition came from the creation of tablebases. I suggest you would not want to turn off 50 move rule when you're not in TB mode. You will have games that may never end. It works fine if you are interested in the cursed wins arising from TB which is what I thought you wanted. If you are looking for more than that , I cant really help you easily.
Thanks. We were looking at analysis, not game-play, and how engines perform (e.g. whether they can solve cursed or non-cursed but very long wins without TB help).

Zenmastur
Posts: 829
Joined: Sat May 31, 2014 6:28 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by Zenmastur » Sun Mar 15, 2020 11:20 pm

Joerg Oster wrote:
Sun Mar 15, 2020 9:35 pm
You might give Moonfish a try. https://github.com/joergoster/Moonfish

If you set "Syzygy50MoveRule" to false, this will also switch it off for the search.
Thanks Joerg. Do you know when using “regular” Stockfish if you turn off the Syzygy50Moverule does the main program still enforce the 50-move-rule. It doesn't seem make sense that it would. I mean, what good would it do to switch it off for TB's and still have the program enforce the rule?

If it does, it seems like this is a bug and needs to be changed.
jp wrote:
Sun Mar 15, 2020 8:53 pm
Zenmastur wrote:
Sun Mar 15, 2020 8:48 pm
SPOILER ALERT - Removing 50-move-rule enforcement WILL change the behavior of the program anytime it finds a mate/capture/pawn push past the 50 move limit.
Can you make changes and try it out to see? (I hope the others with fast machines will be interested too.)
It looks like Joerg has already done that for me. Unfortunately, I'm not set up to compile code. Before I had a heart attack I was considering re-writing a chess program I had written many years ago. After I had my heart attack I decided that I wasn't going to spend a bunch of time on a project that I probably wouldn't be able see thru to fruition. There is another way to test if this is true works or not. I've already done one test that seems to indicate that it does. I'll put it on my "to do" list to do a little more thorough testing when time allows.
Ovyron wrote:
Sun Mar 15, 2020 9:45 pm
Zenmastur wrote:
Sun Mar 15, 2020 8:48 pm
SPOILER ALERT - Removing 50-move-rule enforcement WILL change the behavior of the program anytime it finds a mate/capture/pawn push past the 50 move limit. To suppose otherwise is pure stupidity on your part!
Of course. I'm talking about the problem you're trying to solve by changing that behavior. Will the change help solving the problem?

I'm sure that it will, I just need to make time for the tests.

MikeB wrote:
Sun Mar 15, 2020 9:57 pm
jp wrote:
Sun Mar 15, 2020 1:03 pm
Is there a quick and easy way to hack the Stockfish (or other engines') code so that the 50-move draw rule can be turned off or changed (e.g. to 100 moves)? If so, can you please post here enough details that we can do it?
(Ditto for the threefold repetition rule.)


The motivation is both to look at cursed wins and to see if this helps SF find long wins it currently fails to find that still have DTZ <=100.


e.g.
Zenmastur wrote:
Tue Mar 03, 2020 8:36 pm
If should be noted that it's a COMPLETE waste of time to try to analyze this with ANY engine that enforces the 50-move-rule. <snip>

The problem is that a mate when it's first found is likely to be very long, MUCH longer than the minimum length mate. Then, with additional searching, the mate gets shortened when the engine finds better lines of play. This can NEVER happen if the 50-move-rule is enforced and the first mate found is over 50 moves long.

So, even if the mate is a mate in 49 AND the engine first finds a mate in 73 (for instance), instead of refining the line of play to achieve a shorter mate the engine will disregard the line of play because its over 50 moves long. If it ever finds the mate in 49, it will be by pure luck.

It would be nice if they would put an option to disable the 50-move rule for analysis. But, I'm not holding my breath! So, in the mean time, it's a waste of time to try to analyze positions like this. It's not that Stockfish can't solve it, it's prevented from solving it because of the 50-move-rule.
Uri Blass wrote:
Wed Mar 04, 2020 5:51 pm
If you ignore the 50 move rules things are easier because there are no misleading draw scores by the 50 move rule to hide mates but I think that there still may be a problem of draw score by repetition that is not correct in the hash table because in another line there is no repetition so I suspect that there may be mates that stockfish never find even if you ignore the 50 move rule.

If the last case never happen in stockfish then it may be interesting to understand why.
Stockfish , as do many engines, have a checkbox to turnoff 50 move rule enforcement.
# stockfish
Stockfish 140320 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
uci
id name Stockfish 140320 64 POPCNT
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default
option name Contempt type spin default 24 min -100 max 100
option name Analysis Contempt type combo default Both var Off var White var Black var Both
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 131072
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 84 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name UCI_AnalyseMode type check default false
option name UCI_LimitStrength type check default false
option name UCI_Elo type spin default 1350 min 1350 max 2850
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 7 min 0 max 7
uciok

If you using stockfish under GUI, the GUI also must be able to turn the 50 move off ( usually, since most GUIs on by default). Older versions of Winboard/xBoard, which use polyglot, must also use a hacked version of Polyglot since polyglot also enforces the 50 move rule, which I have if you need it.
I can change this in the GUI I use, unfortunately TB's need to be disabled for the test unless I find a “new” test position that isn't and endgame study. I'm sure there is a position that would fit the bill. I just don't happen to know what it is. Even if I do find an appropriate position that's not and endgame study I would still need to know that when the “Syzygy50Move” is unchecked that the main search also disables 50-move-rule checking. Otherwise it would be a waste of time.

I think I have a way to test this without disabling the 50-move-rule checking. I just need the time to test it. Right now I have about a hundred other things to do. So this will go on my rather long "to-do" list.

Regards,

Zenmastur
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.

User avatar
Ovyron
Posts: 3976
Joined: Tue Jul 03, 2007 2:30 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by Ovyron » Mon Mar 16, 2020 1:56 am

Zenmastur wrote:
Sun Mar 15, 2020 11:20 pm
I'm sure that it will, I just need to make time for the tests.
Strange that you're sure something you haven't tested yet works, against someone that has tested it and says it doesn't. I guess I'll just stop posting spoiler alerts from now on...

User avatar
Ovyron
Posts: 3976
Joined: Tue Jul 03, 2007 2:30 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by Ovyron » Mon Mar 16, 2020 2:00 am

jp wrote:
Sun Mar 15, 2020 1:03 pm
or changed (e.g. to 100 moves)?
For that you change this line:

position.cpp

Code: Select all

  if (st->rule50 > 99 && !is_mate())
      return true;  
The 99 means "99 halfmoves", so to get what you want, you multiply by 2 and subtract 1 (e.g. 30 moves means 30/2-1=59 instead of 99 in the code.) 199 for 100 moves.

Zenmastur
Posts: 829
Joined: Sat May 31, 2014 6:28 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by Zenmastur » Mon Mar 16, 2020 3:12 am

Ovyron wrote:
Mon Mar 16, 2020 1:56 am
Zenmastur wrote:
Sun Mar 15, 2020 11:20 pm
I'm sure that it will, I just need to make time for the tests.
Strange that you're sure something you haven't tested yet works, against someone that has tested it and says it doesn't. I guess I'll just stop posting spoiler alerts from now on...
If you read what I wrote, I did do preliminary tests AND it worked...
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.

MonteCarlo
Posts: 94
Joined: Sun Dec 25, 2016 3:59 pm

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by MonteCarlo » Mon Mar 16, 2020 3:19 am

If we're just wanting to test the idea, it seems it might be simpler to find a difficult TB position where the conversion is ,say, 30 moves away (or some such depth), and see if SF finds the win faster with 50-move ply counter set to 0 than with it at 39, instead of trying to make absolutely sure the engine ignores the 50 move rule.

Just speculating from the armchair, so maybe finding an appropriate position isn't any easier, but it's a thought :)

User avatar
MikeB
Posts: 3939
Joined: Thu Mar 09, 2006 5:34 am
Location: Pen Argyl, Pennsylvania

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by MikeB » Mon Mar 16, 2020 3:29 am

The syzygy tables website will tell you if is a cursed win or not , for 5 , 6 or 7 man endings. There are no cursed wins for 4 man endings or less.

https://syzygy-tables.info/?fen=K7/N7/k ... _w_-_-_0_1

Joerg Oster
Posts: 725
Joined: Fri Mar 10, 2006 3:29 pm
Location: Germany

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by Joerg Oster » Mon Mar 16, 2020 9:59 am

Zenmastur wrote:
Sun Mar 15, 2020 11:20 pm
Joerg Oster wrote:
Sun Mar 15, 2020 9:35 pm
You might give Moonfish a try. https://github.com/joergoster/Moonfish

If you set "Syzygy50MoveRule" to false, this will also switch it off for the search.
Thanks Joerg. Do you know when using “regular” Stockfish if you turn off the Syzygy50Moverule does the main program still enforce the 50-move-rule. It doesn't seem make sense that it would. I mean, what good would it do to switch it off for TB's and still have the program enforce the rule?

If it does, it seems like this is a bug and needs to be changed.
Yes, in regular Stockfish this option only affects the handling of TBs.
The search still enforces the 50-move rule.
I don't think this is a bug but intentional.
Jörg Oster

jp
Posts: 1328
Joined: Mon Apr 23, 2018 5:54 am

Re: Turning off 50-move draw rule in Stockfish & other engines

Post by jp » Mon Mar 16, 2020 10:04 am

Zenmastur wrote:
Sun Mar 15, 2020 11:20 pm
Even if I do find an appropriate position that's not and endgame study I would still need to know that when the “Syzygy50Move” is unchecked that the main search also disables 50-move-rule checking. Otherwise it would be a waste of time.
I assume you wrote this before reading my further exchange of posts with Mike (see above). It apparently doesn't. [And now I see Joerg posted just before this post too.]

The reason they want the option to turn off the rule for TB positions is that under ICCF rules, correspondence games with cursed TB wins are wins:
[2017-015] Any time the 6-piece tablebase applies in an event, the 50-move draw
rule no longer applies once there are only 7 pieces on the board (§2.10.(2))
§2.10.(2) says:
2. As concerns a 6-piece tablebase claim, if the tablebase shows a win that supersedes
the 50 moves rule, the win will be awarded. In a position that is not solvable by the
certified ICCF tablebase, the 50 move rule as described by FIDE Laws of Chess is valid
even in case such a solvable position will arise immediately after the 50th move. In case
the solvable won position arises, and is claimed, before draw according to 50 move rule,
the win will be awarded. [Reference: Playing Rule Guidelines]

There is one other exception to the 50-move rule. If there are a total of 7 pieces
remaining on the board, the 50-move rule no longer applies. [Congress 2017 decision]

But we can ask one of the others involved in the previous discussion to change the code and recompile.

Ovyron wrote:
Mon Mar 16, 2020 2:00 am
position.cpp

Code: Select all

  if (st->rule50 > 99 && !is_mate())
      return true;  
This seems both the easiest and the safest change to make. Just turn off the rule by changing 99 to 10000, or if we want the rule in modified form to some suitable number.

Computer science professors will be getting out their canes for the sinful coder who put a magic number in the code!

Post Reply