|
|
Portable Game NotationFrom Wikipedia, the free encyclopedia. Portable Game Notation (.PGN) is a computer-processable format for recording chess games (both the moves and related data); most chess programs recognize this format. It is structured "for easy reading and writing by human users and for easy parsing and generation by computer programs." The chess moves themselves are given in Algebraic chess notation. Its usual filename extension is ".pgn". There are two formats in the PGN specification, the "import" format and the "export" format. The import format describes data that may have been prepared by hand, and is intentionally lax; a program that can read PGN data should be able to handle the somewhat lax import format. The export format is rather strict and describes data prepared under program control, something like a pretty printed source program reformatted by a compiler. The export format representations generated by different programs on the same computer should be exactly equivalent, byte for byte. PGN code begins with a set of "tag pairs" (a tag name and its value), followed by the "movetext" (chess moves with optional commentary).
Tag PairsTag pairs begin with "[", the name of the tag, the tag value enclosed in double-quotes, and a closing "]". PGN data for archival storage is required to provide 7 tags, termed the STR (Seven Tag Roster). In export format, the STR tag pairs must appear before any other tag pairs that may appear, and in this order:
Many other optional tag pairs are defined by the standard. These include:
MovetextThe movetext describes the actual moves of the game. This may include move number indicators (a number followed by zero or more periods) and movetext Standard Algebraic Notation (SAN). Movetext SAN describe actual moves in a game. In most cases, this is simply the letter abbreviation for the piece, an "x" if there is a capture, and the 2-character algebraic name of the final square the piece moved to. The letter abbreviations are K (King), Q (Queen), R (Rook), B (Bishop), and N (Knight). The pawn is given an empty abbreviation in SAN movetext, but in other contexts the abbreviation "P" is used. The algebraic name of any square is as per usual Algebraic chess notation; from white's perspective, the leftmost square closest to white is a1, while the rightmost square closest to black is h8. In a few cases this can be ambiguous; if so, the piece's file letter, numerical rank, or the exact square is inserted after the moving piece's name (in that order of preference). Thus, "Nge2" move the knight on g to e2. SAN kingside castling is indicated by the sequence "O-O"; queenside castling is indicated by the sequence "O-O-O" (note that these are capital letter Os, not numeral 0s). Pawn promotions are notated by appending an "=" followed by the piece the pawn is promoted to. If the move is a checking move, the plus sign "+" is appended; if the move is a checkmating move, the octothorpe sign "#" is appended (instead). If the game result is anything other than "*", the result is repeated at the end of the movetext. CommentsComments may be added by either a ";" (a comment that continues to the end of the line) or a "{" (which continues until a matching "}"). Comments do not nest. ExampleHere is a sample .PGN: [Event "F/S Return Match"] [Site "Belgrade, Serbia JUG"] [Date "1992.11.04"] [Round "29"] [White "Fischer, Robert J."] [Black "Spassky, Boris V."] [Result "1/2-1/2"]
Handling Chess VariantsVariants of chess may also be recorded using PGN. They are typically noted with a tag named "Variant" giving the name of the rules. Be careful to not use the term "Variation", which means the name of an opening variation instead. Note that many chess programs can only handle at most a few variants. |
|
|