Tips on the PGN format


Answer

On the internet the text based PGN format is the standard format for storing chess games. It is supported by every chess program and thus is extremely important for the exchange of data.

Since the data is saved in a purely text format that means that afterwards the notation can be worked on with any text processing software. Within the PGN format we can store in addition to the notation information such as the names of the players, the year, the result, the code for the opening, comments and variations. Several games or even simply positions can be stored in a PGN file. The disadvantage: in the case of large collections of games the PGN format requires much more space on the hard disk than the specialised file formats.

Below you will find some useful information about the PGN format. A game saved in the PGN format starts with the game data. The following seven data fields are absolutely obligatory for the PGN standard:

1.  [Event "?"]   (name of the tournament, other possible event)

2.  [Site "?"]       (location)

3.  [Date "????.??.??"]  (date)

4.  [Round "?"]  (round)

5.  [White "?"]   (name White)

6.  [Black "?"]     (name Black)

7.  [Result "*"]  (result)

The format with its single line for each data field, square brackets and the quotation marks must be strictly adhered to or else problems when reading the data are inevitable. When entering the date some subtleties must be observed. Inputting the date is required to be in the format YYYY.MM.DD. An example would be e.g. 2019.07.11. Now it will relatively often be the case that the year a game was played is known, but not the month and the day. In such cases you must enter it in the following way: 2019.??.??. As far as entering the result is concerned, four possibilities are open to you, namely 1-0, 1/2-1/2, 0-1, *

In principle PGN files also allow the use of Umlauts and other diacritic marks specific to different languages. Typical examples might be e.g. é, ö etc. Generally speaking, you should avoid the use of such letters since many programs (especially those from English speaking areas) do not handle them correctly. Within PGN files it is absolutely possible to include other entries. Thus it is, for example, also possible to enter descriptions of positions for game fragments which do not set out from the starting position. An example of the description of a position within a PGN files looks like the following:

[Input "1"]

[FEN "2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -"]

The procedure bears a very strong resemblance to the text based EPD format: the game data is followed by an empty line and after it the moves or the notation listed. The notation is easy to understand, it is the usual short form notation with the English shorthand for the pieces (KQRBN).

In doing so you must respect the following conventions:

 

    Before a move for White there is always the move number followed by a full stop and a space.

    For captures an "x" is always used, e.g. dxe5.

    For checks a  "+" is to be used, e.g. Bb5+.

    Checkmate must be marked with a "#", e.g. Qh4#.

    For castling use the capital "O" (not the figure "0"), e.g. O-O-O.

   Drawing moves (stalemate, repetition of the position, 50 move rule) are not marked.

    En passant captures are not marked as such.

    When a pawn is promoted, then an "=" stands before the piece to which it is promoted, e.g. e8=Q.

When the game notation has been listed, there follows another space, then the result and then a blank line. Each line may contain a maximum of 79 characters and must (if required ) then be wrapped to the next one. PGN files can also contain annotations and variations and, at least theoretically, there is no limit regarding the number of games which can be stored in a single PGN file.

You will certainly now be asking whether you absolutely have to know all this structure. As a rule you do not have to since our programs do the conversion automatically. But as is always the case in life, the same applies to standards, e.g. to the PGN standard. All are compatible, many even more compatible. It can always happen that you are unable to read what is for you an important PGN file because some of the conventions have not been properly implemented or adhered to. In such a case you must make use of a text editor and yourself "Enter manually."

Tags
Created on
10.07.2019
Rating
Feedback

Back to List