Triple Repitition: Is this considered a repitition or not?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Triple Repitition: Is this considered a repitition or no

Post by syzygy »

Teemu Pudas wrote:
syzygy wrote:
Teemu Pudas wrote:
syzygy wrote:This "deficiency" only leads to the engine "unknowingly" walking into a draw on very rare occasions, provided that the GUI or whatever entity is overseeing the game strictly keeps to the FIDE rules...
Or you could err in the other direction and keep EP information out of the repetition hash key entirely.
But that seems dangerous. It could cause the engine to stop playing before the game actually finishes and it could lead to an occasional big oversight because the search (hitting the hashtable) does not see the ep capture at all.
Note I specifically said repetition hash key.
Then you need to do extra effort, maintaining two hash keys or something, just to make the repetition hash key wrong more often than necessary. And it may still cause the engine to stop playing before the game actually finishes.
Teemu Pudas
Posts: 88
Joined: Wed Mar 25, 2009 12:49 pm

Re: Triple Repitition: Is this considered a repitition or no

Post by Teemu Pudas »

syzygy wrote:Then you need to do extra effort, maintaining two hash keys or something, just to make the repetition hash key wrong more often than necessary.
repkey = hashkey ^ zob_ep(epsquare); // local variable

If the line from the EP-ful position to the EP-less position is optimal, then it is also optimal to repeat the EP-less position (or actually the position immediately following the EP-ful position). If the line isn't optimal, there's no reason to continue searching. This will occasionally save some search effort and sometimes even make the search return a more accurate result.
syzygy wrote:And it may still cause the engine to stop playing before the game actually finishes.
If your engine stops playing for any other reason than because the GUI has stopped telling it to play or because it would be illegal to continue the game, you have a bug anyway.
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Triple Repitition: Is this considered a repitition or no

Post by syzygy »

Teemu Pudas wrote:
syzygy wrote:Then you need to do extra effort, maintaining two hash keys or something, just to make the repetition hash key wrong more often than necessary.
repkey = hashkey ^ zob_ep(epsquare); // local variable

If the line from the EP-ful position to the EP-less position is optimal, then it is also optimal to repeat the EP-less position (or actually the position immediately following the EP-ful position). If the line isn't optimal, there's no reason to continue searching. This will occasionally save some search effort and sometimes even make the search return a more accurate result.
I see your point and I guess you're right.
syzygy wrote:And it may still cause the engine to stop playing before the game actually finishes.
If your engine stops playing for any other reason than because the GUI has stopped telling it to play or because it would be illegal to continue the game, you have a bug anyway.
That's not a bug if it's by design. The only reason to play on is to accommodate for GUI bugs. In case of a draw by repetition playing on is not really problematic, but in case of a 50-move draw it is. The last move played by the engine might allow mate-in-1 by the opponent were it not for the correctness of the engine's assumption that the 50-move rule will kick in. If the engine cannot rely on the GUI getting that right, then the GUI is useless. (Oh, and what UCI thinks about what engines should or should not do cannot bother me too much.)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Triple Repitition: Is this considered a repitition or no

Post by bob »

syzygy wrote:
Teemu Pudas wrote:
syzygy wrote:Then you need to do extra effort, maintaining two hash keys or something, just to make the repetition hash key wrong more often than necessary.
repkey = hashkey ^ zob_ep(epsquare); // local variable

If the line from the EP-ful position to the EP-less position is optimal, then it is also optimal to repeat the EP-less position (or actually the position immediately following the EP-ful position). If the line isn't optimal, there's no reason to continue searching. This will occasionally save some search effort and sometimes even make the search return a more accurate result.
I see your point and I guess you're right.
syzygy wrote:And it may still cause the engine to stop playing before the game actually finishes.
If your engine stops playing for any other reason than because the GUI has stopped telling it to play or because it would be illegal to continue the game, you have a bug anyway.
That's not a bug if it's by design. The only reason to play on is to accommodate for GUI bugs. In case of a draw by repetition playing on is not really problematic, but in case of a 50-move draw it is. The last move played by the engine might allow mate-in-1 by the opponent were it not for the correctness of the engine's assumption that the 50-move rule will kick in. If the engine cannot rely on the GUI getting that right, then the GUI is useless. (Oh, and what UCI thinks about what engines should or should not do cannot bother me too much.)
Actually I think you HAVE to play on to be legal. 3-fold is not a mandatory end-of-game condition. Your opponent can repeat a 3rd time and not claim the draw, and you are free to then either immediately claim the draw without moving, or you can play something that breaks the repetition and force the game to continue...

Crafty recognizes 3-fold just fine, but it will continue to play through it if desired.
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Triple Repitition: Is this considered a repitition or no

Post by syzygy »

bob wrote:Actually I think you HAVE to play on to be legal. 3-fold is not a mandatory end-of-game condition. Your opponent can repeat a 3rd time and not claim the draw, and you are free to then either immediately claim the draw without moving, or you can play something that breaks the repetition and force the game to continue...
So just claim it. Same with 50-move rule.

Again, if I would let my engine play after a 3-fold repetition nothing bad should happen, but in case of the 50-move rule it could get mated on the next move. That's not optional: it MUST claim the draw. And if the GUI does not understand draw offers, then the GUI MUST adjudicate as a draw. If the GUI is too dumb for that, it is too dumb for my engine.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Triple Repitition: Is this considered a repitition or no

Post by bob »

syzygy wrote:
bob wrote:Actually I think you HAVE to play on to be legal. 3-fold is not a mandatory end-of-game condition. Your opponent can repeat a 3rd time and not claim the draw, and you are free to then either immediately claim the draw without moving, or you can play something that breaks the repetition and force the game to continue...
So just claim it. Same with 50-move rule.

Again, if I would let my engine play after a 3-fold repetition nothing bad should happen, but in case of the 50-move rule it could get mated on the next move. That's not optional: it MUST claim the draw. And if the GUI does not understand draw offers, then the GUI MUST adjudicate as a draw. If the GUI is too dumb for that, it is too dumb for my engine.
There are two sides to every game. If your opponent makes a move that repeats for the third time, he can claim a draw after making his move. If he doesn't make the claim, you have the option of making the claim before you make a move, or even after you make a move it that also produces a 3-fold repetition, or you can play a move that doesn't repeat and the game goes on. Just because you recognize the 3-fold repetition and the opponent doesn't does not eliminate the potential problem of stopping when you see that technically the game should have ended...

I agree that if the GUI is broken, nothing will work correctly. But the 50 move and 3-fold repetition rules do not necessarily end the game...
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Triple Repitition: Is this considered a repitition or no

Post by syzygy »

bob wrote:
syzygy wrote:
bob wrote:Actually I think you HAVE to play on to be legal. 3-fold is not a mandatory end-of-game condition. Your opponent can repeat a 3rd time and not claim the draw, and you are free to then either immediately claim the draw without moving, or you can play something that breaks the repetition and force the game to continue...
So just claim it. Same with 50-move rule.

Again, if I would let my engine play after a 3-fold repetition nothing bad should happen, but in case of the 50-move rule it could get mated on the next move. That's not optional: it MUST claim the draw. And if the GUI does not understand draw offers, then the GUI MUST adjudicate as a draw. If the GUI is too dumb for that, it is too dumb for my engine.
There are two sides to every game. If your opponent makes a move that repeats for the third time, he can claim a draw after making his move. If he doesn't make the claim, you have the option of making the claim before you make a move, or even after you make a move it that also produces a 3-fold repetition, or you can play a move that doesn't repeat and the game goes on. Just because you recognize the 3-fold repetition and the opponent doesn't does not eliminate the potential problem of stopping when you see that technically the game should have ended...

I agree that if the GUI is broken, nothing will work correctly. But the 50 move and 3-fold repetition rules do not necessarily end the game...
syzygy wrote:So just claim it.
Are we in repetition mode again?