Draw by 3 fold repetition...

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Draw by 3 fold repetition...

Post by syzygy »

Pi4Chess wrote: Tue Dec 29, 2020 5:12 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pm
Pi4Chess wrote: Mon Dec 28, 2020 9:46 pm
Uri Blass wrote: Mon Dec 28, 2020 9:30 pm
If you think that some move should be different then you should give a position and say what move stockfish played and what it should play based on your opinion.
I am just asking those who know how engines are coded why a top engine like stockfish "accepts" to get into a position where the opponent can draw by 3 fold repetition with forced King's check. Is it unavoidable ? Is this took into account enough to discard certain moves from others within its evaluation ?
I am just asking.
Because SF prefers 0.00 over -0.01.
How it chooses between 2 0.00 moves?
First come, first served. An alpha-beta search does not even get to know that the second move is 0.00 and not <0.00.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Draw by 3 fold repetition...

Post by syzygy »

Ras wrote: Tue Dec 29, 2020 3:23 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pmBecause SF prefers 0.00 over -0.01.
With the standard contempt of 24, that would be preferring 0.00 over -0.25, no?
It would be preferring -0.24 over -0.25. If a draw is evaluated as -0.24, then moves leading to a -0.23 evaluation would be preferred over moves leading to a draw.
Pi4Chess
Posts: 253
Joined: Mon Nov 16, 2020 12:13 pm
Full name: Manuel Rivera

Re: Draw by 3 fold repetition...

Post by Pi4Chess »

syzygy wrote: Tue Dec 29, 2020 8:43 pm
Pi4Chess wrote: Tue Dec 29, 2020 5:12 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pm
Pi4Chess wrote: Mon Dec 28, 2020 9:46 pm
Uri Blass wrote: Mon Dec 28, 2020 9:30 pm
If you think that some move should be different then you should give a position and say what move stockfish played and what it should play based on your opinion.
I am just asking those who know how engines are coded why a top engine like stockfish "accepts" to get into a position where the opponent can draw by 3 fold repetition with forced King's check. Is it unavoidable ? Is this took into account enough to discard certain moves from others within its evaluation ?
I am just asking.
Because SF prefers 0.00 over -0.01.
How it chooses between 2 0.00 moves?
First come, first served. An alpha-beta search does not even get to know that the second move is 0.00 and not <0.00.
Oh..
jp
Posts: 1470
Joined: Mon Apr 23, 2018 7:54 am

Re: Draw by 3 fold repetition...

Post by jp »

The Play Magnus engine does appear not to know the 3-fold-repetition rule, allowing draws in totally winning positions. Glaurung (on which it was based) is open source. It might be interesting to look inside the code to see what's going on.
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: Draw by 3 fold repetition...

Post by Ovyron »

syzygy wrote: Tue Dec 29, 2020 8:43 pm
Pi4Chess wrote: Tue Dec 29, 2020 5:12 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pm Because SF prefers 0.00 over -0.01.
How it chooses between 2 0.00 moves?
First come, first served. An alpha-beta search does not even get to know that the second move is 0.00 and not <0.00.
Depends on the implementation, I recall Rebel Decade used to be able to switch from some 0.00 move to another, or from any score to another move of the same score. I believe it did it when it spent more time on the move it switched to (not that this move is any better, but I'll play it instead so all this time wasn't wasted.)

The logic is sound (specially when memory is scarce, and this new move has overwritten hash contents of the old one), though I don't know if it remains like this in latest versions of ProDeo.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Draw by 3 fold repetition...

Post by syzygy »

Ovyron wrote: Sat Mar 20, 2021 3:13 pm
syzygy wrote: Tue Dec 29, 2020 8:43 pm
Pi4Chess wrote: Tue Dec 29, 2020 5:12 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pm Because SF prefers 0.00 over -0.01.
How it chooses between 2 0.00 moves?
First come, first served. An alpha-beta search does not even get to know that the second move is 0.00 and not <0.00.
Depends on the implementation
Not when it implements alpha-beta.
I recall Rebel Decade used to be able to switch from some 0.00 move to another, or from any score to another move of the same score. I believe it did it when it spent more time on the move it switched to (not that this move is any better, but I'll play it instead so all this time wasn't wasted.)
Perhaps in such cases the new move failed high, which means new score > 0.00 (> old score), and the engined displayed 0.00 (old score) as the known lower bound. With more time it would then figure out its exact score.
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: Draw by 3 fold repetition...

Post by Ovyron »

syzygy wrote: Sun Mar 21, 2021 10:22 amPerhaps in such cases the new move failed high, which means new score > 0.00 (> old score), and the engined displayed 0.00 (old score) as the known lower bound. With more time it would then figure out its exact score.
Rebel Decade never displayed fails lows, only exact scores (a failing high move would not replace a current one until its exact score was known).

Another possibility is that it truncated scores (say, move is scored 0.001, new move scores 0.002, both truncate to 0.00, user sees engine switch from move A to move B with same score.)

This was a common occurrence.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Draw by 3 fold repetition...

Post by hgm »

Virtually all engines with >2000 Elo do recognize 3-fold repetitions as draws. And as a consequence they will avoid the opponent forcing them on them when they think non-repeating alternatives score better.

If they nevertheless allow them to happen when there are better alternatives, it was just because they did not search deep enough to see them coming.

Why don't engines just search so deep that they would always see everything infinitely far in advance? Well, I suppose you can guess the answer to that yourself...
Uri Blass
Posts: 10269
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Draw by 3 fold repetition...

Post by Uri Blass »

syzygy wrote: Sun Mar 21, 2021 10:22 am
Ovyron wrote: Sat Mar 20, 2021 3:13 pm
syzygy wrote: Tue Dec 29, 2020 8:43 pm
Pi4Chess wrote: Tue Dec 29, 2020 5:12 pm
syzygy wrote: Tue Dec 29, 2020 3:20 pm Because SF prefers 0.00 over -0.01.
How it chooses between 2 0.00 moves?
First come, first served. An alpha-beta search does not even get to know that the second move is 0.00 and not <0.00.
Depends on the implementation
Not when it implements alpha-beta.
I recall Rebel Decade used to be able to switch from some 0.00 move to another, or from any score to another move of the same score. I believe it did it when it spent more time on the move it switched to (not that this move is any better, but I'll play it instead so all this time wasn't wasted.)
Perhaps in such cases the new move failed high, which means new score > 0.00 (> old score), and the engined displayed 0.00 (old score) as the known lower bound. With more time it would then figure out its exact score.
It is possible to add some small random number to the evaluation so
alphabeta can prefer one draw and not another draw because draws(including draws by repetition) are not exactly 0.00.

In this case if there are many moves that allow you to force repetitions after the move you play and the opponent does not have many option to get a draw then you can expect the score to become higher and I think that it can help the engine to play better in some cases because if you have many paths that lead to draw by repetition then there is a better probability that you miss something because of not searching deep enough and you have more than a draw.