"My opponent left a glass of whisky 'en prise' and I took it 'en passant". - Henry Blackburne | SINCE 2007

Thursday, February 25, 2016

Towards a replacement for the PGN format

The PGN format has been a common format for recording chess games for a long time. Is it time we changed it? Play Magnus guys discuss. 

Since it was introduced more than twenty years ago, Portable Game Notationhas been by far the most widespread and portable format for exporting, importing and sharing annotated chess games in the software world. Even today, it remains a fundamental part of computer chess infrastructure.
However, as groundbreaking as PGN was back when it was introduced (at a time where no open and widely implemented document format for chess games existed), time has moved on, and modern chess software struggles to work around the various limitations in PGN.
At Play Magnus, we're working on a new chess game file format that we hope can replace PGN in the future, and that can also be used in many situations where the limitations in PGN makes it too awkward to use. We already use an early version of this new format internally. It will take a while before we are ready to publish a specification, for a number of reasons: The format is still rapidly evolving, as we keep discovering new features that we need. Along with the specification itself, we'd like to have some open source libraries for reading and manipulating games in the new format, as well as some friendly end-user software for producing and consuming content. And finally, since we've got an awful lot of other work to do, we can't prioritize this task as much as I'd like. We don't expect the new format to be ready for external use before some time towards the end of the year (and that's an optimistic estimate).
The reason we bring up the work on the new format so far in advance is that we'd like to give the wider community a chance to share their thoughts about what they want to see in the new format, and what limitations in PGN annoy them the most.
Here are a few of the most significant weaknesses and limitations we've identified so far:
  1. PGN is designed to be somewhat humanly readable, at the expense of making it harder for computer software to parse and produce. We believe this is a design mistake. Few users read PGN without the help of some kind of software anyway, and writing a working PGN parser is needlessly hard – even more so because in practice you also need to be able to parse all the subtly broken PGN that's produced by other programs that fail to implement the spec 100% correctly.
  2. PGN is ASCII encoded, making it unsuitable for both player names and textual annotations in most of the world. A modern format should obviously support Unicode (in fact, many recent implementations of PGN do permit Unicode, even though this is technically breaking the standard).
  3. No support for including engine analysis in the game. Various programs do support annotating games with engine analysis, but only using the standard PGN mechanisms of comments and recursive annotation variations. Data like search depths and evaluations are included as textual comments, and the syntax of these comments vary from program to program. This makes it difficult to exchange computer annotated games between different pieces of software.
  4. No support for formatted text in comments – not even paragraphs. In our new format, we're toying with the idea of using some kind of Markdown for comments, including support for things like images, videos and hyperlinks.
  5. No top-level elements other than games. We'd like to be able to group the games into rounds and tournaments, and to produce ebook-like documents with chapters and text between the games.
  6. Variations can only appear after the main move in a position, and not before. Often the annotator wants to present some variations before the move that was played in the game, in order to explain her choice of move. For instance, it is not unusual to first present the move you were originally planning to play along with some variations, the explain why you decided that it doesn't work, and how you arrived at some other move (the one you ended up playing) instead.
  7. No support for null moves in variations. This makes it impossible to annotate a move with something like "threatening 31. Nx7 Kxg7 32. Rg1+ Kh8 33. h6, with a strong attack" (except in a purely textual comment, where you can't play through the moves).
If you have other PGN annoyances you would like to see addressed in a new format (or if you have comments to the above list), please let us know about them, and there's a chance we can consider your wishes while developing the format.

No comments: