Geras1mleo/Chess

Wrong Fen

zakkoo opened this issue · 2 comments

Describe the bug
After first move "e2" to "e4" the method "ToFen()" returns wrong value. In this case the En-Passant move is shown, but actually it should not be there since there is no black pawn that could capture. If you import this wrong Fen to Lichess for example, it fails.

To Reproduce
var cb = new ChessBoard();
cb.Move(new Move("e2", "e4");
var fen = cb.ToFen();

Expected behaviour
fen --> rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1

Actual behaviour
fen --> rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

@Geras1mleo If you want I can fix it. Let me know.

@zakkoo thank you for your enthusiasm! When developing I saw the difference in behavior between lichess and chess.com fen generation for en-passant. I've chosen to use the chess.com approach (move verbose). If you need the lichess behavior, I would like you to implement it yourself. You can add an initializer ( get; init; ) as AutoEndgameRules (but Boolean) into ChessBoard class to configure/extend the behavior of FenBoardBuilder.GetEnPassantTargetSquare() or ChessBoard.LastMoveEnPassantPosition()

Thank you for your contribution to open source in advance!