PGN format Issue

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
jshriver
Posts: 1357
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

PGN format Issue

Post by jshriver »

One of my programs generates a pgn database based on observed fics games.
From what i've read the format seems fine, but when I load it into scid I get the following error:

x: Error: PGN Header tag seen inside game

where x is the line before where each new game starts.
Is there a specific tag you have to add at the end of each game formally? Here is an example: (some moves left out to save space)

[White "GuestBHCG"]
[Black "GuestYZVZ"]
[WhiteElo "unrated"]
[BlackElo "unrated"]
[Result "1-0"]
[Date "2008.Oct.7"]

1 d4 Nf6
2 a3 g6
3 b4 d5
4 Bb2 Bg7
5 e3 O-O
...
31 Ne5 Rd6
32 Qc7 Qd4
33 Qxf7+

[White "Guest"]
[Black "Guest"]
etc..

The line right above [White "Guest"] is where scid is throwing the error. (still seems to load it fine though)
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: PGN format Issue

Post by sje »

The very last token it a PGN game text must be a Game Termination Marker. The five possible GTM strings are:

1-0 0-1 1/2-1/2 * 0-0

Your example is missing one of these.
User avatar
jshriver
Posts: 1357
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: PGN format Issue

Post by jshriver »

Neat thank you will give that a shot.
Harald
Posts: 318
Joined: Thu Mar 09, 2006 1:07 am

Re: PGN format Issue

Post by Harald »

jshriver wrote:One of my programs generates a pgn database based on observed fics games.
From what i've read the format seems fine, but when I load it into scid I get the following error:

x: Error: PGN Header tag seen inside game

where x is the line before where each new game starts.
Is there a specific tag you have to add at the end of each game formally? Here is an example: (some moves left out to save space)

[White "GuestBHCG"]
[Black "GuestYZVZ"]
[WhiteElo "unrated"]
[BlackElo "unrated"]
[Result "1-0"]
[Date "2008.Oct.7"]

1 d4 Nf6
2 a3 g6
3 b4 d5
4 Bb2 Bg7
5 e3 O-O
...
31 Ne5 Rd6
32 Qc7 Qd4
33 Qxf7+

[White "Guest"]
[Black "Guest"]
etc..

The line right above [White "Guest"] is where scid is throwing the error. (still seems to load it fine though)
Steven gave you the important information to avoid the error.
Here is a minor bug. Your output does not follow this rule:
8.1.1: Seven Tag Roster

There is a set of tags defined for mandatory use for archival storage of PGN
data. This is the STR (Seven Tag Roster). 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.

For import format, the order of tag pairs is not important. For export format,
the STR tag pairs appear before any other tag pairs. (The STR tag pairs must
also appear in order; this order is described below). Also for export format,
any additional tag pairs appear in ASCII order by tag name.

The seven tag names of the STR are (in order):

1) Event (the name of the tournament or match event)

2) Site (the location of the event)

3) Date (the starting date of the game)

4) Round (the playing round ordinal of the game)

5) White (the player of the white pieces)

6) Black (the player of the black pieces)

7) Result (the result of the game)

A set of supplemental tag names is given later in this document.

For PGN export format, a single blank line appears after the last of the tag
pairs to conclude the tag pair section. This helps simple scanning programs to
quickly determine the end of the tag pair section and the beginning of the
movetext section.
It is easier for PGN parsers if they see a correct STR.

And even less important:
8.2.2.2: Export format move number indications

There are two export format move number indication formats, one for use
appearing immediately before a white move element and one for use appearing
immediately before a black move element. A white move number indication is
formed from the integer giving the fullmove number with a single period
character appended. A black move number indication is formed from the integer
giving the fullmove number with three period characters appended.

All white move elements have a preceding move number indication. A black move
element has a preceding move number indication only in two cases: first, if
there is intervening annotation or commentary between the black move and the
previous white move; and second, if there is no previous white move in the
special case where a game starts from a position where Black is the active
player.

There are no other cases where move number indications appear in PGN export
format.
Harald