11

I want to read a PGN file and then advance to a certain move number, and feed that to an UCI engine. Turns out engines work using long algebraic notation, and PGNs are in short algebraic. What is an easy way to make the conversion? i.e. from SAN to LAN.

I realize that generating long algebraic notation requires knowledge of the board state & chess rules, so I don't want to write it all again! Surely something like this must already exist - either a command line program or a module (preferably in python).

  • 2
    This question appears to be off-topic because it is about programming, not about chess. – Tony Ennis Sep 28 '13 at 12:25
  • 2
    AFAIK, the most explicit meta discussion there's been that's pertinent to whether this is on-topic is meta.chess.stackexchange.com/q/100/167. The consensus at that point seemed to be that something like this should be considered on-topic. (Note: I'm not arguing one way or the other, so don't take it up with me. But do feel free to contribute to that meta thread.) – ETD Sep 28 '13 at 15:07
7

Would this be what you are looking for? PGN-extract (A command line utility) http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/

I can see a flag in the feature doc that might help:

  • -W[cm|epd|halg|lalg|elalg|san|uci] - specify the output format to use
    -Whalg is hyphenated long algebraic.
    -Wlalg is long algebraic
    -Welalg[PNBRQK] is enhanced long algebraic. Use the characters PNBRQK for language
  • 2
    The best option for the person who asked is probably -Wuci if they want to feed it to an UCI engine. – Vegard Nov 25 '16 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.