Skip to content

Conversation

@lenguyenthanh
Copy link
Member

@lenguyenthanh lenguyenthanh commented Apr 18, 2025

This include some changes on pgn.Parser to include the raw value of San in it's ADT, which is needed for us to return better error messages. This also matches chessops library's error messages.

here are two examples:

pgn:

1. e6
- Cannot play Pawn e6
+ Cannot play e6 at move 1 by White

pgn:

e3 Nc6 d4 Nf6 c3 e5 dxe5 Nxe5 Bb5 a6 Ba4 b5 Bb3 d5 e4 dxe4 f4 Qxd1+ Kxd1 Nd3 Be3 Ng4 Bd4 Ngf2+ Bxf2 Nxf2+ Ke1 Nxh1 Bd5 Ra7 Bc6+ Kd8 Bxe4 Bd6 g3 Re8 Nd2 f5 Ne2 fxe4 Kf1 e3 Kg2 exd2 Rxh1 Bb7+ Kf2 Bc5+ Kf3 d1=Q#
- Cannot play King f3
+ Cannot play Kf3 at move 25 by black

@lenguyenthanh lenguyenthanh force-pushed the pgn-parser/error-messages branch from 8ae5055 to d61e959 Compare April 18, 2025 09:22
@ornicar
Copy link
Collaborator

ornicar commented Apr 18, 2025

instead of at move 25, ply 49 wouldn't it more human-friendly to say at move 25 by black?

@lenguyenthanh
Copy link
Member Author

lenguyenthanh commented Apr 18, 2025

instead of at move 25, ply 49 wouldn't it more human-friendly to say at move 25 by black?

makes sense, yeah, I was copying error message from: lichess-org/lila#17362 (comment)

Will update

By utilizing the new included rawString in san representation, we can
display to users where (with its raw value) it's failed to replay the
game.
@lenguyenthanh lenguyenthanh force-pushed the pgn-parser/error-messages branch from d61e959 to 043fec8 Compare April 18, 2025 11:05
@lenguyenthanh lenguyenthanh merged commit f0fd8a1 into lichess-org:master Apr 18, 2025
3 checks passed
@lenguyenthanh lenguyenthanh deleted the pgn-parser/error-messages branch April 18, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants