- Blind mode tutorial
lichess.org
Donate

Probably minor bug in fen strings (en passant).

I noticed, that the ep field in your fen strings only shows if a capture is actually possible.
But according to the fen definition, the ep field should be shown when a pawn moves two squares.
For example: White plays e4 on the first move, e3 should show up as ep square.

Personally I think, your solution is even better but it can lead to problems when comparing fens taken from lichess with fens taken from somewhere else. A lot of positions that are the same would show as different because one fen has the ep square included and the other doesn't.

Sources:

  1. https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation
    Quote: En passant target square in algebraic notation. If there's no en passant target square, this is "-". If a pawn has just made a two-square move, this is the position "behind" the pawn. This is recorded regardless of whether there is a pawn in position to make an en passant capture.

  2. http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm
    Quote:
    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.
.
.
.
16.1.4: Examples

Here's the FEN for the starting position:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

And after the move 1. e4:

rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

I noticed, that the ep field in your fen strings only shows if a capture is actually possible. But according to the fen definition, the ep field should be shown when a pawn moves two squares. For example: White plays e4 on the first move, e3 should show up as ep square. Personally I think, your solution is even better but it can lead to problems when comparing fens taken from lichess with fens taken from somewhere else. A lot of positions that are the same would show as different because one fen has the ep square included and the other doesn't. Sources: 1. https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation Quote: En passant target square in algebraic notation. If there's no en passant target square, this is "-". If a pawn has just made a two-square move, this is the position "behind" the pawn. This is recorded regardless of whether there is a pawn in position to make an en passant capture. 2. http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm Quote: 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. . . . 16.1.4: Examples Here's the FEN for the starting position: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 And after the move 1. e4: rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

Hello,

It's done on purpose because we need compatibility with chess960 fen (x-fen standard), see https://github.com/ornicar/lila/issues/1570 for more explanation.

Hello, It's done on purpose because we need compatibility with chess960 fen (x-fen standard), see https://github.com/ornicar/lila/issues/1570 for more explanation.

Ok. But it is not quite X-Fen either.
Try the following position:
1nbqkbnr/1ppppppp/8/r5PK/p7/5P2/PPPPP2P/RNBQ1BNR b k - 3 11
Now black plays f5 and ep does not show because white cant legally take.
But the X-Fen standard would allow the square to be shown.

I propose you call it Li-Fen and define it as a new standard ;)
Its clearly better then Fen and X-Fen, but if you call it Fen people expect it to behave like Fen.

Source: https://en.wikipedia.org/wiki/X-FEN
Quote: However, it is possible that even if an X-FEN records an en passant square, making that capture would be illegal, because after the capture the king of the capturing player would be in check.

Ok. But it is not quite X-Fen either. Try the following position: 1nbqkbnr/1ppppppp/8/r5PK/p7/5P2/PPPPP2P/RNBQ1BNR b k - 3 11 Now black plays f5 and ep does not show because white cant legally take. But the X-Fen standard would allow the square to be shown. I propose you call it Li-Fen and define it as a new standard ;) Its clearly better then Fen and X-Fen, but if you call it Fen people expect it to behave like Fen. Source: https://en.wikipedia.org/wiki/X-FEN Quote: However, it is possible that even if an X-FEN records an en passant square, making that capture would be illegal, because after the capture the king of the capturing player would be in check.

This topic has been archived and can no longer be replied to.