HOME

TheInfoList



OR:

Portable Game Notation (PGN) is a standard
plain text In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.). It may also include a limit ...
format for recording
chess Chess is a board game for two players, called White and Black, each controlling an army of chess pieces in their color, with the objective to checkmate the opponent's king. It is sometimes called international chess or Western chess to dist ...
games (both the moves and related
data In the pursuit of knowledge, data (; ) is a collection of discrete Value_(semiotics), values that convey information, describing quantity, qualitative property, quality, fact, statistics, other basic units of meaning, or simply sequences of sy ...
), which can be read by humans and is also supported by most chess software.


History

PGN was devised around 1993, by Steven J. Edwards, and was first popularized and specified via the
Usenet Usenet () is a worldwide distributed discussion system available on computers. It was developed from the general-purpose Unix-to-Unix Copy (UUCP) dial-up network architecture. Tom Truscott and Jim Ellis conceived the idea in 1979, and it wa ...
newsgroup rec.games.chess.


Usage

PGN is structured "for easy reading and writing by human users and for easy
parsing Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from L ...
and generation by
computer program A computer program is a sequence or set of instructions in a programming language for a computer to execute. Computer programs are one component of software, which also includes documentation and other intangible components. A computer program ...
s." The chess moves themselves are given in
algebraic chess notation Algebraic notation (or AN) is the standard method for recording and describing the moves in a game of chess. It is based on a system of coordinates to uniquely identify each square on the chessboard. It is used by most books, magazines, and news ...
using English initials for the pieces. The
filename extension A filename extension, file name extension or file extension is a suffix to the name of a computer file (e.g., .txt, .docx, .md). The extension indicates a characteristic of the file contents or its intended use. A filename extension is typically ...
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 source program reformatted by a
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
. The export format representations generated by different programs on the same computer should be exactly equivalent, byte for byte. PGN text 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
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because ...
text. The tag value is enclosed in double-quotes, and the tag is then terminated with a closing right bracket . A quote inside a tag value is represented by the backslash immediately followed by a quote. A backslash inside a tag value is represented by two adjacent backslashes. There are no special control codes involving escape characters, or carriage returns, and linefeeds to separate the fields, and superfluous embedded spaces are usually skipped when parsing.


Seven Tag Roster

PGN data for archival storage is required to provide seven tag pairs – together known as the "''Seven Tag Roster''". In export format, these tag pairs must appear before any other tag pairs and in this order:


Optional tag pairs

The standard allows for other optional tag pairs. The more common ones include:


Movetext

Chessboard notation, frame The movetext describes the actual moves of the game. This includes move number indicators (numbers followed by either one or three periods; one if the next move is White's move, three if the next move is Black's move) and movetext in 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 two-character algebraic name of the final square the piece moved to. The letter abbreviations are K (
king King is the title given to a male monarch in a variety of contexts. The female equivalent is queen, which title is also given to the consort of a king. *In the context of prehistory, antiquity and contemporary indigenous peoples, the tit ...
), Q (
queen Queen or QUEEN may refer to: Monarchy * Queen regnant, a female monarch of a Kingdom ** List of queens regnant * Queen consort, the wife of a reigning king * Queen dowager, the widow of a king * Queen mother, a queen dowager who is the mother ...
), R (
rook Rook (''Corvus frugilegus'') is a bird of the corvid family. Rook or rooks may also refer to: Games *Rook (chess), a piece in chess *Rook (card game), a trick-taking card game Military * Sukhoi Su-25 or Rook, a close air support aircraft * USS ...
), B (
bishop A bishop is an ordained clergy member who is entrusted with a position of authority and oversight in a religious institution. In Christianity, bishops are normally responsible for the governance of dioceses. The role or office of bishop is c ...
), and N (
knight A knight is a person granted an honorary title of knighthood by a head of state (including the Pope) or representative for service to the monarch, the church or the country, especially in a military capacity. Knighthood finds origins in the Gr ...
). The
pawn Pawn most often refers to: * Pawn (chess), the weakest and most numerous piece in the game * Pawnbroker or pawnshop, a business that provides loans by taking personal property as collateral Pawn may also refer to: Places * Pawn, Oregon, an his ...
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; from white's perspective, the leftmost square closest to white is a1, the rightmost square closest to the white is h1, and the rightmost (from white's perspective) square closest to black side is h8. In a few cases, a more detailed representation is needed to resolve ambiguity; if so, the piece's
file File or filing may refer to: Mechanical tools and processes * File (tool), a tool used to ''remove'' fine amounts of material from a workpiece **Filing (metalworking), a material removal process in manufacturing ** Nail file, a tool used to gent ...
letter, numerical
rank Rank is the relative position, value, worth, complexity, power, importance, authority, level, etc. of a person or object within a ranking, such as: Level or position in a hierarchical organization * Academic rank * Diplomatic rank * Hierarchy * ...
, 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 This glossary of chess explains commonly used terms in chess, in alphabetical order. Some of these terms have their own pages, like ''fork'' and '' pin''. For a list of unorthodox chess pieces, see Fairy chess piece; for a list of terms specific ...
castling is indicated by the sequence O-O; queenside castling is indicated by the sequence O-O-O (note that these are capital Os, not zeroes, contrary to the FIDE standard for notation). Pawn promotions are notated by
append In computer programming, append is the operation for concatenating linked lists or arrays in some high-level programming languages. Lisp Append originates in the Lisp programming language. The append procedure takes zero or more (linked) lists a ...
ing = to the destination square, followed by the piece the pawn is promoted to. For example: e8=Q. If the move is a checking move, + is also appended; if the move is a checkmating move, # is appended instead. For example: e8=Q#. An annotator who wishes to suggest alternative moves to those actually played in the game may insert variations enclosed in parentheses. They may also comment on the game by inserting Numeric 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 are inserted by either a ; (a comment that continues to the end of the line) or a ). Comments do not nest.


Example

Here is the PGN format of the 29th game of the 1992 match played in
Yugoslavia Yugoslavia (; sh-Latn-Cyrl, separator=" / ", Jugoslavija, Југославија ; sl, Jugoslavija ; mk, Југославија ;; rup, Iugoslavia; hu, Jugoszlávia; rue, label=Pannonian Rusyn, Югославия, translit=Juhoslavija ...
between
Bobby Fischer Robert James Fischer (March 9, 1943January 17, 2008) was an American chess grandmaster and the eleventh World Chess Champion. A chess prodigy, he won his first of a record eight US Championships at the age of 14. In 1964, he won with an 1 ...
and Boris Spassky:


Handling chess variants

Many chess variants 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 is used to record the starting position for variants (such as
Chess960 Fischer random chess, also known as Chess960 (often read in this context as 'chess nine-sixty' instead of 'chess nine hundred sixty'), is a variation of the game of chess invented by the former world chess champion Bobby Fischer. Fischer annou ...
) which have initial positions other than the orthodox chess initial position.


See also

* X-FEN *
Smart Game Format The Smart Game Format (SGF) is a computer file format used for storing records of board games. Go is the game that is most commonly represented in this format and is the default. SGF was originally created under a different name by Anders Kie ...
– Format for recording go games *
Portable Draughts Notation Portable Draughts Notation (.PDN) is the standard computer-processable format for recording draughts games. This format is derived from Portable Game Notation, which is the standard chess format. PDN files are text files which must contain Tag P ...


References

{{Chess Chess notation Computer file formats 1993 introductions