All Topics  
Portable Game Notation

 

   Email Print
   Bookmark   Link






 

Portable Game Notation



 
 
Portable Game Notation (PGN) is a computer
Computer

A computer is a machine that manipulates Data according to a list of Code .The first devices that resemble modern computers date to the mid-20th century , although the computer concept and various machines similar to computers existed earlier....
-processible format for recording chess
Chess

Chess is a recreational and competitive game played between two Player . Sometimes called Western chess or international chess to distinguish it from History of chess and other chess variants, the current form of the game emerged in Southern Europe during the second half of the 15th century after evolving from similar, much older...
 games (both the moves and related data
DATA

Debt, AIDS, Trade in Africa is a multinational Non-governmental organization founded in January 2002 in London by U2's Bono along with Robert Sargent Shriver III and activists from the Jubilee 2000 Drop the Debt campaign....
); many chess programs recognize this extremely popular format due to its accessibility by ordinary ASCII editors, including word processors capable of importing and exporting plain ASCII
ASCII

American Standard Code for Information Interchange , is a coding standard that can be used for interchanging information, if the information is expressed mainly by the written form of English words....
.

Usage
PGN is structured "for easy reading and writing
Writing

Writing is the representation of language in a textual Media through the use of a set of signs or symbols . It is distinguished from illustration, such as cave drawing and painting, and the recording of language via a non-textual medium such as Magnetic tape sound recording....
 by human
Human

A human being, also human or man, is a member of a species of bipedalism primates in the family Hominidae . Mitochondrial DNA evidence indicates that modern humans originated in east Africa about 200,000 years ago....
 users and for easy parsing
Parsing

In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a sequence of lexical analysis#Token to determine their grammatical structure with respect to a given formal grammar....
 and generation
Generation

Generation , also known as reproduction, is the act of producing offspring. In a more generic sense, it can also refer to the act of creating something inanimate such as electricity generation or cryptography code generation....
 by computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
s." The chess moves themselves are given in algebraic chess notation
Algebraic chess notation

Algebraic chess notation is used to record and describe the moves in a game of chess. It is now standard among all chess organizations and most books, magazines, and newspapers....
.






Discussion
Ask a question about 'Portable Game Notation'
Start a new discussion about 'Portable Game Notation'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Portable Game Notation (PGN) is a computer
Computer

A computer is a machine that manipulates Data according to a list of Code .The first devices that resemble modern computers date to the mid-20th century , although the computer concept and various machines similar to computers existed earlier....
-processible format for recording chess
Chess

Chess is a recreational and competitive game played between two Player . Sometimes called Western chess or international chess to distinguish it from History of chess and other chess variants, the current form of the game emerged in Southern Europe during the second half of the 15th century after evolving from similar, much older...
 games (both the moves and related data
DATA

Debt, AIDS, Trade in Africa is a multinational Non-governmental organization founded in January 2002 in London by U2's Bono along with Robert Sargent Shriver III and activists from the Jubilee 2000 Drop the Debt campaign....
); many chess programs recognize this extremely popular format due to its accessibility by ordinary ASCII editors, including word processors capable of importing and exporting plain ASCII
ASCII

American Standard Code for Information Interchange , is a coding standard that can be used for interchanging information, if the information is expressed mainly by the written form of English words....
.

History


PGN was devised in around 1993, by Steven J. Edwards, and was first popularized via the Usenet
Usenet

Usenet, a portmanteau of "user" and "network", is a worldwide distributed Internet discussion system. It evolved from the general purpose UUCP architecture of the same name....
 newsgroup rec.games.chess.

Usage


PGN is structured "for easy reading and writing
Writing

Writing is the representation of language in a textual Media through the use of a set of signs or symbols . It is distinguished from illustration, such as cave drawing and painting, and the recording of language via a non-textual medium such as Magnetic tape sound recording....
 by human
Human

A human being, also human or man, is a member of a species of bipedalism primates in the family Hominidae . Mitochondrial DNA evidence indicates that modern humans originated in east Africa about 200,000 years ago....
 users and for easy parsing
Parsing

In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a sequence of lexical analysis#Token to determine their grammatical structure with respect to a given formal grammar....
 and generation
Generation

Generation , also known as reproduction, is the act of producing offspring. In a more generic sense, it can also refer to the act of creating something inanimate such as electricity generation or cryptography code generation....
 by computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
s." The chess moves themselves are given in algebraic chess notation
Algebraic chess notation

Algebraic chess notation is used to record and describe the moves in a game of chess. It is now standard among all chess organizations and most books, magazines, and newspapers....
. The usual filename extension
Filename extension

A filename extension is a substring to the filename of a computer file applied to indicate the encoding convention of its contents.In some operating systems it is optional, while in some others it is a requirement....
 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, similar to a pretty printed
Prettyprint

Prettyprint is the application of any of various stylistic formatting conventions to Text-based , source code, Markup language, and other similar kinds of content....
 source program reformatted by a compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
. 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).

Tag pairs


Tag pairs begin with an initial left bracket "[", followed by the name of the tag in plain text (ASCII
ASCII

American Standard Code for Information Interchange , is a coding standard that can be used for interchanging information, if the information is expressed mainly by the written form of English words....
). The tag value is enclosed in double-quotes, and the tag is then terminated with a closing right bracket "]". There are no special control codes involving escape characters, or carriage returns and linefeeds to separate the fields, and superfluous embedded spaces (or SPC characters) are usually skipped when parsing.

PGN data for archival storage is required to provide seven bracketed fields, referred to as "tags" and together known as 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
    International Olympic Committee

    The International Olympic Committee is an organization based in Lausanne, Switzerland, created by Pierre de Coubertin and Demetrios Vikelas on June 23, 1894....
     code
    List of IOC country codes

    The International Olympic Committee uses three letter acronym country codes to refer to each group of athletes that participate in the Olympic Games....
     for the country. An example is "New York City
    New York City

    The City of New York is the List of United States cities by population in the United States, while the New York metropolitan area ranks among the List of urban areas by population....
    , NY USA
    United States

    The United States of America is a Federal government constitutional republic comprising U.S. state and a federal district. The country is situated mostly in central North America, where its Contiguous United States and Washington, D.C., the Capital districts and territories, lie between the Pacific Ocean and Atlantic Oceans, Borders of the U...
    ".
  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 within the event.
  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).


The standard allows for supplementation in the form of other, optional, tag pairs. The more common tag pairs 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
    Forsyth-Edwards Notation

    Forsyth-Edwards Notation is a standard Chess notation for describing a particular board position of a Chess game. The purpose of FEN is to provide all the necessary information to restart a game from a particular position....
    . 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 have its value set to "1".


Movetext


The movetext describes the actual moves of the game. This includes move number indicators (numbers followed by either one or three periods; one if preceding a move by White, three if preceding a move by Black) and movetext Standard Algebraic Notation (SAN).

For most moves the SAN consists of 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
King (chess)

In chess, the King is the most important chess piece. The object of the game is to trap the opponent's king so that he would not be able to avoid capture ....
), Q (Queen
Queen (chess)

The queen is the most powerful chess piece in the game of chess. Each player starts the game with one queen, placed in the middle of their first rank next to their King ....
), R (Rook
Rook (chess)

A rook is a chess piece in the strategy board game of chess. In the past the piece was called the castle, tower, marquess, rector, and comes , and non-players still often call it a "castle"....
), B (Bishop
Bishop (chess)

A bishop is a Chess piece in the board game of chess. Each player begins the game with two bishops. One starts between the king's Knight and the King , the other between the queen's knight and the Queen ....
), and N (Knight
Knight (chess)

The knight is a chess piece in the game of chess, representing a knight . It is normally represented by a horse's head, leading some to refer to it informally as a "horse"....
). 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
Algebraic chess notation

Algebraic chess notation is used to record and describe the moves in a game of chess. It is now standard among all chess organizations and most books, magazines, and newspapers....
; from white's perspective, the leftmost square closest to white is a1, the rightmost square closest to white is h1, and the rightmost square closest to black is h8.

In a few cases a more detailed representation is needed to resolve ambiguity; 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" specifies that the knight originally on the g-file moves to e2.

SAN kingside castling
Castling

Castling is a special move in the game of chess involving the king and either of the original rook of the same color. Castling consists of moving the king two squares towards a rook, then moving the rook onto the square over which the king crossed....
 is indicated by the sequence "O-O"; queenside castling is indicated by the sequence "O-O-O" (note that these are capital letter O's, not numeral 0's). 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 number sign
Number sign

'Number sign' is a name for the symbol '#'; it is the preferred Unicode name for the code point associated with that glyph. The symbol is similar to the musical symbol called Sharp ....
 "#" is appended instead.

An annotator who wishes to suggest alternative moves to those actually played in the game may insert variations enclosed in parentheses. He may also comment on the game by inserting Numerical Annotation Glyphs (NAGs) into the movetext. Each NAG reflects a subjective impression of the move preceding the NAG or of the resultant position.

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 ""). Comments do not nest.

Example

Here is a sample game in PGN format:

[Event "F/S Return Match"] [Site "Belgrade
Belgrade

Belgrade is the capital and largest city of Serbia. The city lies on international waterway, at the confluence of the Sava River and Danube rivers, where the Pannonian Plain meets the Balkan Peninsula....
, Serbia
Serbia

Serbia , officially the Republic of Serbia , is a country in Central Europe and Balkans Europe, covering the southern part of the Pannonian Plain and the central part of the Balkans....
 JUG
Yugoslavia

File:LocationYugoslavia2.pngYugoslavia is a term that describes three political entities that existed successively on the Balkan Peninsula in Europe, during most of the 20th century....
"] [Date "1992.11.04"] [Round "29"] [White "Fischer, Robert J.
Bobby Fischer

Robert James "Bobby" Fischer was an United States and Icelandic chess Grandmaster , and the eleventh World Chess Champion.As a teenager, Fischer became famous as a chess prodigy....
"] [Black "Spassky, Boris V."] [Result "1/2-1/2"]   1. e4 e5 2. Nf3 Nc6 3. Bb5 3... 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

Handling chess variants

Many chess variants
Chess variant

A chess variant is a game derived from, related to or similar to chess in at least one respect. The difference from chess can include one or more of the following:...
 can be recorded using PGN, provided the names of the pieces can be limited to one character, usually a letter and not a number. They are typically noted with a tag named "Variant" giving the name of the rules. The term "Variation" must be avoided, as that refers to the name of an opening variation. Note that traditional chess programs can only handle, at most, a few variants. Forsyth-Edwards Notation
Forsyth-Edwards Notation

Forsyth-Edwards Notation is a standard Chess notation for describing a particular board position of a Chess game. The purpose of FEN is to provide all the necessary information to restart a game from a particular position....
 (FEN) is used to record the starting position for variants (such as Chess960
Chess960

Chess960, or Fischer Random Chess , is a chess Chess variantinvented by the late former World Chess Champion Bobby Fischer by modifying the rules of Shuffle Chess so that castling possibilities exist for all starting positions....
) which have initial positions other than the orthodox chess initial position.

Plycount is a chess term for the total number of moves in a game, counting each player's move as 1. It is an optional part of the standard PGN description of a chess game.

See also

  • X-FEN
    X-FEN

    X-FEN is an extension of Forsyth-Edwards Notation .The traditional Forsyth-Edwards Notation is not sufficient to represent all possible positions in 8x8 Chess960 or 10x8 Capablanca random chess ....
  • Smart Game Format
    Smart Game Format

    The Smart Game Format, or SGF, is a computer file format used for storing records of board games including:*Go *Lines of Action*Backgammon...
  • Portable Draughts Notation
    Portable Draughts Notation

    Portable Draughts Notation is the standard computer-processable format for recording draughts games. This format is derived from Portable Game Notation, which is the standard chess format....


External links