Home Learn to Play Chess Improve Your Game Chess History Chess for Fun Chess Blog
|Portable Game Notation (PGN)|
|Downloading games is a popular chess activity on the Internet. PGN makes it simple.|
Computers and the Internet have had a profound impact on the game of chess. Opening & game databases, tactical calculation, endgame tablebases, online & email play, computer vs. computer, vs. human, algorithm & game theory, have all been with us for less than an average human lifetime.
The advances in chess have paralleled the advances in computing. The first mainframes to play chess knew little more than how the pieces moved. The best programs today, running on tiny processors, easily beat all but the best human players. One of the greatest advances in the last ten years has been the ability to exchange game scores in digital formats. This has led to databases of millions of games that can be searched in a few seconds.
All commercial chess database software is built around some database format which is proprietary to that software. Databases in that format can be exchanged only between owners of the software. A more general exchange of data between owners of incompatible software packages requires a neutral format which is understood by both packages.
Fortunately for the chess world a neutral format was created in the mid-1990s and caught on quickly. It's called Portable Game Notation (PGN). Files using PGN encoding are usually assigned the extension *.PGN. Here's a sample game in PGN format.
The format is defined in a document called the PGN Specification and Implementation Guide which can be found on the Web. The document defines all necessary formats for encoding chess game data using text files.
A PGN game score has two sections, formally known as the:-
The tag pairs are the lines enclosed in square brackets ('[' and ']'). Each tag pair consists of a tag name plus its value. In the tag pair '[Event "chp"]', 'Event' is the tag name and 'chp' is its value. It's clear from the tags that the game score is the well-known 'Game of the century' which 13-year old Bobby Fischer won against Donald Byrne in the 1956 U.S. Championship.
The movetext section is the game score in algebraic notation, which the PGN document calls Standard Algebraic Notation (SAN). The document defines details like 'O-O' instead of '0-0' for castling, and '=' for promotions ('c8=Q').
The tags in the Byrne - Fischer example ('Event', 'Site', 'Date', 'Round', 'White', 'Black', & 'Result') are collectively known as the Seven Tag Roster (STR). [In the computer world everything gets an acronym. There's the famous story of the technician who was confused by the meaning of 'FAN' on a schematic until he was told to look it up in the dictionary.]
Every PGN game score is required to have those seven tags. The PGN document says, 'The interpretation of these tags is fixed as is the order in which they appear. Although the definition and use of additional tag names and semantics is permitted and encouraged when needed, the STR is the common ground that all programs should follow for public data interchange.' If the value of one of the seven tags is unknown, it is filled with '?', as seen in the 'Round' tag from the example.
Other tags in common use are 'ECO', which gives the ECO classification, and 'Annotator', which gives the name of the person annotating the game. Yes, the PGN document standardizes the format for game comments. It also doesn't require a game to start from the initial position. The 'FEN' tag (Forsyth-Edwards Notation), described in the document, can be used to specify any legal chess position.
The great advantage of PGN is that it can be read and easily understood by people and by computers. Written in 1994 by Steven J. Edwards, the PGN document saw widespread distribution via the Internet and within a few years had become *the* standard. Today it is rare to see a text file using any other standard.
What are the disadvantages of the PGN standard? One common complaint is that its text-based encoding is not particularly efficient. The same data in ChessBase format uses about half the disk space. Web site operators with large chess databases often prefer to distribute their data in ChessBase or other format to save on disk costs. Even when compressed using ZIP, the space savings of a chess-specific format are substantial.
Another disadvantage is that there are no general guidelines for the values. The 'Site' tag value is often crammed into the 'Event' tag or vice versa. The values can be terse to the point of incomprehensible : [Event "ct"] means a candidates tournament. Players names are not written uniformly in all databases and not every chess program knows that Chirov and Shirov can be the same person.
But these problems are insignificant compared to the advantages of PGN. Searching and downloading game files is one of the most popular chess activities on the Internet, and PGN can take a lot of credit for this popularity. The quote from the introduction to the PGN document...
If now, while they are one people, all speaking the same language, they have started to do this, nothing will later stop them from doing whatever they propose to do. - Genesis XI, v.6
...is apt indeed.