Triple Repitition: Is this considered a repitition or not?

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.
jayakiran
Posts: 9
Joined: Tue Apr 12, 2016 8:15 pm

Triple Repitition: Is this considered a repitition or not?

Post by jayakiran » Sat May 07, 2016 8:24 am

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: 23716
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

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

Post by hgm » Sat May 07, 2016 8:30 am

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: 3826
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

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

Post by Sven » Sat May 07, 2016 8:36 am

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 8:15 pm

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

Post by jayakiran » Sat May 07, 2016 8:40 am

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

Have a good day.

Jayakiran

syzygy
Posts: 4455
Joined: Tue Feb 28, 2012 10:56 pm

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

Post by syzygy » Sat May 07, 2016 4:27 pm

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 11:49 am

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

Post by Teemu Pudas » Sun May 08, 2016 2:27 pm

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: 4455
Joined: Tue Feb 28, 2012 10:56 pm

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

Post by syzygy » Sun May 08, 2016 4:40 pm

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: 4455
Joined: Tue Feb 28, 2012 10:56 pm

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

Post by syzygy » Sun May 08, 2016 4:50 pm

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 8:15 pm

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

Post by jayakiran » Mon May 09, 2016 6:30 pm

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 11:49 am

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

Post by Teemu Pudas » Thu May 12, 2016 1:50 pm

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.

Post Reply