Triple Repitition: Is this considered a repitition or not?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jayakiran
Posts: 9
Joined: Tue Apr 12, 2016 10:15 pm

Triple Repitition: Is this considered a repitition or not?

Post by jayakiran »

Hi guys -

Q: A position is repeated 3 times (same castling rights each time), but the first time the position was arrived by a double pawn push (but no possible en-passant captures - either because there were no capturing pawns or because an ep-capture would be illegal...) - is this considered a repitition or not according to FIDE rules?

From an evaluation point of view, the three positions are identical, as they have the exact same legal moves.

I would love to hear from people on this and any comments from experienced people would be appreciated. Thanks!

Jayakiran
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

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

Post by hgm »

According to FIDE rules it would be a repetition. En-passant rights are only supposed to be present when there is an actual Pawn that can make such a capture.

This is different from castling rights; those are supposed to exist (and thus make the position different) even if you cannot actually castle, and even if there is no possible sequence of legal moves from the given position that could ever make you castle. (E.g. because you are in check, and the only way to resolve it is move your King.)
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

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

Post by Sven »

jayakiran wrote:Hi guys -

Q: A position is repeated 3 times (same castling rights each time), but the first time the position was arrived by a double pawn push (but no possible en-passant captures - either because there were no capturing pawns or because an ep-capture would be illegal...) - is this considered a repitition or not according to FIDE rules?

From an evaluation point of view, the three positions are identical, as they have the exact same legal moves.

I would love to hear from people on this and any comments from experienced people would be appreciated. Thanks!

Jayakiran
Yes, this is considered a repetition. FIDE rules state in article 9.2:
Positions are considered the same if and only if the same player has the move, pieces of the same kind and colour occupy the same squares and the possible moves of all the pieces of both players are the same.
jayakiran
Posts: 9
Joined: Tue Apr 12, 2016 10:15 pm

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

Post by jayakiran »

hgm/Sven - thanks for the explanation and reference. Clears it up for me.

Have a good day.

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

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

Post by syzygy »

I think this is a point where it is acceptable for an engine to deviate slightly from what the FIDE rules consider to be a repetition. It is not difficult to test for absence or presence of adjacent pawns that could potentially capture en passant, but checking those captures for legality is probably not worth the effort.

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...

Do we know that all GUIs and chess servers etc. implement this perfectly? If not, it is probably better for the engine not to be perfect here either...
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: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.
syzygy
Posts: 5557
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: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.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

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

Post by syzygy »

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.
About that last point: since the first time the position occurs in the search is immediately after the double pawn push, the score in the hashtable will probably assume that the ep capture IS possible even though it may not.

Also note that never hashing en passant information will usually be wrong, whereas always hashing en passant information will only be wrong in the case that the EP capture happens to be illegal. (I am assuming en passant information is not hashed if there is no pseudolegal ep capture, which is easy to check for.)
jayakiran
Posts: 9
Joined: Tue Apr 12, 2016 10:15 pm

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

Post by jayakiran »

Interesting idea to ignore legality of the ep capture.

My MoveGen does legal moves only with the help of stored attack information (has to be computed after make-move). So, it's trivial to compute legality of en_passant capture (I have stored the pins and those pesky en_passant pins - where the two pawns are pinned to the king by a rook/queen horizontally). It's not too slow (perft 6 in 7.5 sec). So, I basically went with considering only legal ep capture for hash. The idea for me is to implement a repetition table (store number of repetitions for each Zobrist hash seen so far - I'm gonna ignore hash collisions of course).

As a related question - to test the accuracy of a repetition table - is there an existing program that counts the number of triple repetitions until a certain depth (a la perft node count). Basically count all unique continuations from the root that lead to triple repetition (until the given depth). Any program you guys know that already does that - so I can compare against?

I realize that I might be needlessly worrying about this bit of the engine - but just want to see if I can do it right without too much speed cost.
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:
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.