Encyclopedia > Portable Game Notation

  Article Content

Portable Game Notation

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).

Table of contents

Tag Pairs

Tag 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:

  1. Event: the name of the tournament or match event.
  2. Site: the location of the event. This is in "City, Region COUNTRY" format, where COUNTRY is the 3-letter International Olympic Committee code for the country. An example is "New York City, NY USA".
  3. Date: the starting date of the game, in YYYY.MM.DD form. "??" are used for unknown values.
  4. Round: the playing round ordinal of the game.
  5. White: the player of the white pieces, in "last name, first name" format.
  6. Black: the player of the black pieces, same format as White.
  7. Result: the result of the game. This can only have four possible values: "1-0" (White won), "0-1" (Black won), "1/2-1/2" (Draw), or "*" (other, e.g., the game is ongoing).

Many other optional tag pairs are defined by the standard. These include:

  • Time: Time the game started, in "HH:MM:SS" format, in local clock time.
  • Termination: Gives more details about the termination of the game. It may be "abandoned", "adjudication" (result determined by third-party adjudication), "death", "emergency", "normal", "rules infraction", "time forfeit", or "unterminated".
  • FEN: The initial position of the chess board, in Forsyth-Edwards Notation. This is used to record partial games (starting at some initial position). It is also necessary for chess variants such as Fischer Random Chess, where the initial position is not always the same as traditional chess. If a FEN tag is used, a separate tag pair "SetUp" must also appear and be have its value set to "1".

Movetext

The 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". 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.

Comments

Comments 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.

Example

Here 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"]
 
 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3
 O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15.
 Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21.
 Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7
 27. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33.
 f3 Bc8 34. Kf2 Bf5 35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb5
 40. Rd6 Kc5 41. Ra6 Nf2 42. g4 Bd3 43. Re6 1/2-1/2

References:


See also: Smart Game Format



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
North Lindenhurst, New York

... 91.6 males. The median income for a household in the town is $59,022, and the median income for a family is $63,642. Males have a median income of $42,403 versus $31,296 ...

 
 
 
This page was created in 41.7 ms