PGN 101

PGN 101

Samad1
Samad1
Mar 19, 2016, 3:20 PM |
1

Many chess programs and websites - including our beloved chess.com - generate PGN files and allow us to export or download them. As the number of the games grow, it's good to be able to archive them properly, add comments, annotations and extra information to the games without any hassle. 

Personally I create a PGN file for each OTB tournament I play which contains all the games I played in that tournament (and store them in a file like 2016-03-reykjavik-9.pgn). I analyze them and add annotation and comments where needed. So when I go through them again later, I would know where I made mistakes, where I had better alternatives, etc. A coach may create a PGN file of dozens of similar tactics for her students, a player might create a file of all the master games won by black in certain variation of Sicilian Najdorf, or endgames with rook + three pawns versus rook + 2 pawns. Different people may use them differently and for different purposes.

PGN stands for Portable Game Notation and was invented by Steven J. Edwards in 1993.

PGN files have .pgn extension and are plain text files (as opposed to binary) which means you can open them using any simple text editor, modify them or simply create them from scratch (well the latter might not be very 21st century-ish!). Most chess programs or websites offer such functionality to create them for us (or read them) but knowing a little bit about it might come handy at times.

Each PGN file may contain a single game OR many games. If there are more than one game they're normally separated by an empty line. So you can just copy any number of games in a single file each separated by an empty line and save them as one PGN file.

Each game consists of some header tags which are basic information regarding the game (date, location, players, etc) and a body containing the moves.

Headers:
There are many headers, some are used more often, some not that often and some are just specific to the program/website creating them. Here are the most common header tags:

[Event "SOME_EVENT"]
[Site "SOME_PLACE"]
[Round "3"]
[White "DOE, JOHN"]
[Black "ROE, RICHARD"]
[WhiteElo "1268"]
[BlackElo "1103"]
[Date "2014.07.12"]
[ECO "B35"]
[Result "1-0"]

None of the fields need to be filled with actual information of course. There are many other headers like [Board "3"] which represents the number of the board in team matches and headers for time control, etc.

Body:
Body contains the moves and the result. If the result is not clear * is added at the end instead of the actual result and for draw 1/2-1/2 is used.
There also can be comments, annotations and variations and more!

  • Moves:
    1.e4 e5 2.Bc4 Bc5 3.Qh5 g6 4.Qxe5+ Kf8 5.Qxc5+ d6 6.Qd5 Nc6 7.Qxf7# 1-0

    You can of course have each move in one line for better readability:
    1.e4 e5
    2.Bc4 Bc5
    3.Qh5 g6

    But normally it doesn't matter since you'll be using a game viewer.
  • Comments:
    For comments curly braces are used:
    1.e4 e5 2. Nf3 Nc6 3. Bb5 Nf6 {another Berlin Defense} 4.O-O Be7 5.Re1 d6 6.c3 O-O {he spent almost 20 minutes here} 7.d3 {black resigned!!!}
  • Annotations:
    For annotation glyph $ (dollar sign) is used with a number after the move. The most useful ones:
    $1 ....  ! (good move)
    $2 .... ? (poor move)
    $3 .... !! (brilliant)
    $4 .... ?? (blunder)
    $5 .... !? (speculative/interesting)
    $6 .... ?! (questionable)
    $10 ... = (drawish/equal)
    $16 ... ± (slight advantage white)
    $17 ... ∓ (slight advantage black)
    $18 ... +- (decisive advantage white)
    $19 ... -+ (decisive advantage black)

    For example:
    3.Qh5 g6 $4 4.Qxe5+ $1 Kf8 
    will translate to:
    3.Qh5 g6?? 4.Qxe5+! Kf8
    in the game viewer.

  • Variations:
    For variations, parenthesis are used:
    1.e4 e5 2.Nf3 Nc6 3.Bb5 ( 3.Bc4 Bc5 4.c3 ) 3...a6 4.Ba4
    The variations can be nested of course and have comments or annotations of their own.

Time:
Normally time related info are for games played online and so generated by the websites, chess programs or digital boards. It is allowed to write the time in your scoresheet and so some players do. The times can be embedded into a comment after the move, Time control itself can be added into header tags though:
[TimeControl "600"] means 10 minutes (600 seconds) for each player
[TimeControl "5400+30"] would mean 90 minutes for each player (5400 seconds) and 30 seconds increment for each move
[TimeControl "40/7200:3600"] would mean 2 hours for the first 40 moves and 1 hour for the rest.

For adding times for moves the most common ways are to use %clk which represents the total remaining time or %emt which represents the elapsed time for the preceding move.

For example:
1.c4 {[%clk 1:30:57]} c6 {[%clk 1:30:46]} 2.d4 {[%clk 1:31:03]} d5 {[%clk 1:31:06]} 3.Nf3 {[%clk 1:31:20]} Nf6 {[%clk 1:31:18]}
Or
1.e4 {[%emt 0.0]} c5 {[%emt 0.0]} 2.Nc3 {[%emt 2.6]} Nc6 {[%emt 0.2]} 3.Nf3 {[%emt 2.5]} g6 {[%emt 1.2]}

Different starting position:
If the starting position of the game is different than the standard position (i.e. starting after some moves have already been played) then a FEN tag is added in the header.

FEN (Forsyth–Edwards Notation) is a static representation of the position. Meaning we don't know anything about the moves that led to the current position and the moves that were played afterwards, we just know what the current position looks like. Now it's easy to understand FEN and you can read all about it here , but to summerize it shows:

  • where the pieces are
  • whose turn it is
  • which castles are available
  • whether there's an en passant available

The header tag looks like something like:
[FEN "8/3R1pk1/7p/4PK2/5P1P/8/r7/8 b - - 0 1"]

Here are a few example PGNs and how they look in chess.com's viewer:

[Event "Candidates 2016"]
[Site "Moscow"]
[Round "1.3"]
[White "Anand, Viswanathan"]
[Black "Svidler, Peter"]
[WhiteElo "2762"]
[BlackElo "2757"]
[Date "2016.03.17"]
[ECO "C88"]
[Result "1-0"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 O-O 8. a4 Bb7 9. d3 Re8 10. Nbd2 Bf8 11. c3 Na5 12. Bc2 c5 13. d4 exd4 14. cxd4 d5 15. e5 Ne4 16. axb5 axb5 17. Nxe4 dxe4 18. Rxe4 Nb3 19. Rxa8 Bxa8 20. Ng5 Nxc1 21. Qh5 h6 22. Qxf7+ Kh8 23. Rg4 23... Qa5 24. h4 1-0

[Event "Legal Trap"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "Sire de Legal"]
[Black "?"]
[Result "1-0"]
[ECO "C50"]

1.e4 e5
2.Nf3 Nc6
3.Bc4 d6
4.Nc3 Bg4 $6 {Black pins the knight in the fight over the center. Strategically this is a sound idea, but there is a tactical flaw with the move.}
5.h3 Bh5 $2 {Black apparently maintains the pin, but this is a tactical blunder which loses at least a pawn}
6.Nxe5 $1 {The tactical refutation. White seemingly ignores the pin and surrenders the queen.} Bxd1 $4
({Black's best course now is to play:} 6...Nxe5 7.Qxh5 Nxc4 8.Qb5+ c6 9.Qxc4 {White remains a pawn ahead, but Black can at least play on.})
7.Bxf7+ Ke7
8.Nd5# 1-0
[Event "Paris"]
[Site "Paris FRA"]
[Date "1859.03.31"]
[EventDate "?"]
[Round "?"]
[Result "1-0"]
[White "Paul Morphy"]
[Black "Schrufer"]
[ECO "C56"]
[FEN "r6r/pppkq1Np/2nb4/6N1/3p4/8/PPP1QPPP/R1B3K1 w - - 0 16"]

16.Qg4+ Kd8 17.Nf7+ Qxf7 18.Bg5+ Be7 19.Ne6+ Kc8 $4 20.Nc5+ Kb8 21.Nd7+ Kc8 22.Nb6+ Kb8 23.Qc8+ Rxc8 24.Nd7# 1-0
 
Alright that's it. Hope you'll find it helpful and if there's any question, please shoot!