Hi,
the original topic of this thread was repetition detection with en passant, so I suggest to come back to it. The castling question has been solved now, I think.
"Repetition and en passant" has some more potential to be considered.
The PGN standard says about en passant target squares in FENs (
http://www.yacdb.com/pgn/pgn_1616.htm#SEC16.1.3.4):
- Code: Select all
16.1.3.4: En passant target square
The fourth field is the en passant target square. If there is no en passant target square then the single character symbol "-" appears. If there is an en passant target square then is represented by a lowercase file character immediately followed by a rank digit. Obviously, the rank digit will be "3" following a white pawn double advance (Black is the active color) or else be the digit "6" after a black pawn double advance (White being the active color).
An en passant target square is given if and only if the last move was a pawn advance of two squares. Therefore, an en passant target square field may have a square name even if there is no pawn of the opposing side that may immediately execute the en passant capture.
The last sentence is interesting. It means that engines should not implement their repetition detection code (and/or "makemove" code that affects the ep square information of the new position) exactly after that FEN rule because otherwise they would end up in not detecting the following:
A pawn makes a double step but there is no enemy pawn present "that may immediately execute the en passant capture". Now the next, say, four plies are such that the position of all pieces after the pawn double step is repeated (and castling rights did not change, of course). According to FIDE rules this is a repetition because the right to make an ep capture is identical in both positions (i.e., no ep capture possible). Example:
[diag]8/3k4/8/8/8/3K4/5P2/8 w - - 0 1[/diag]
8/3k4/8/8/8/3K4/5P2/8 w - - 0 1
FEN from WinBoard 4.2.7 after 1.f4:
8/3k4/8/8/5P2/3K4/8/8 b - f3 0 1
FEN from WinBoard 4.2.7 after 1.f4 Ke7 2.Ke3 Kd7 3.Kd3:
8/3k4/8/8/5P2/3K4/8/8 b - - 0 3
So I think that engines should either set the ep square after makemove() only if an enemy pawn is present to the left or to the right (this is what "Surprise" does, for example), or should set the ep square as FEN specification requires but then consider the "enemy pawn condition" during repetition detection if a nonzero ep square is found for both positions being compared (perhaps only for the current pos).
How do the other engine authors address this?
- And now I even want to top it. What about pins?
Consider this example:
[diag]8/8/6k1/8/4K1pr/8/5P2/6R1 w - - 0 1[/diag]
8/8/6k1/8/4K1pr/8/5P2/6R1 w - - 0 1
Here after 1.f4 no ep capture is allowed because Pg4 is pinned. But according to the standard we get the following FEN after 1.f4:
8/8/6k1/8/4KPpr/8/8/6R1 b - f3 0 1
Does anyone detect in his/her engine that the ep square should be empty in this case, too? If so, how do you do it?
Cheers,
Sven