Portable Game Notation

Last updated
Filename extension
.pgn
Internet media type
application/vnd.chess-pgn
Developed by Steven J. Edwards
Initial release1993;31 years ago (1993)
Type of format Chess game record

Portable Game Notation (PGN) is a standard plain text format for recording chess games (both the moves and related data), which can be read by humans and is also supported by most chess software.

Contents

History

PGN was devised around 1993, by Steven J. Edwards, and was first popularized and specified [1] via the Usenet newsgroup rec.games.chess. [2]

Usage

PGN is structured "for easy reading and writing by human users and for easy parsing and generation by computer programs." The chess moves themselves are given in algebraic chess notation using English initials for the pieces. The filename extension 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. 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 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:

EventName of the tournament or match event.
SiteLocation of the event. This is in City, Region COUNTRY format, where COUNTRY is the three-letter International Olympic Committee code for the country. An example is New York City, NY USA.
Although not part of the specification, some online chess platforms will include a URL or website as the site value. [3]
DateStarting date of the game, in YYYY.MM.DD form. ?? is used for unknown values.
RoundPlaying round ordinal of the game within the event.
WhitePlayer of the white pieces, in Lastname, Firstname format.
BlackPlayer of the black pieces, same format as White.
ResultResult of the game. It is recorded as White score, dash, then Black score, or * (other, e.g., the game is ongoing).

Optional tag pairs

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

Annotator The person providing notes to the game.
PlyCount String value denoting the total number of half-moves played.
TimeControl e.g. 40/7200:3600 (moves per seconds: sudden death seconds)
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.
ModeOTB (over-the-board) ICS (Internet Chess Server)
FEN The initial position of the chessboard, in Forsyth–Edwards Notation. This is used to record partial games (starting at some initial position). It is also necessary for chess variants such as Chess960, 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

Chessboard notation SCD algebraic notation.svg
Chessboard notation

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), Q (queen), R (rook), B (bishop), and N (knight). 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; 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 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 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). [4] Pawn promotions are notated by appending = 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 { (which continues until a }). Comments do not nest.

Example

Here is the PGN format of the 29th game of the 1992 match played in Yugoslavia between Bobby Fischer and Boris Spassky:

[Event "F/S Return Match"][Site "Belgrade, Serbia JUG"][Date "1992.11.04"][Round "29"][White "Fischer, Robert J."][Black "Spassky, Boris V."][Result "1/2-1/2"]  1.e4 e5 2.Nf3 Nc6 3.Bb5 {This opening is called the Ruy Lopez.} 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 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) which have initial positions other than the orthodox chess initial position.

Numeric Annotation Glyphs

Numeric Annotation Glyphs or NAGs are used to annotate chess games when using a computer, typically providing an assessment of a chess move or a chess position. NAGs exist to indicate a simple annotation in a language independent manner. NAGs were first formally documented in 1994 by Steven J. Edwards in his "Portable Game Notation Specification and Implementation Guide". [5] Within the PGN specification, 256 NAGs are proposed of which the first 140 are defined; the remainder were reserved for future definition.

A Numeric Annotation Glyph is composed of a dollar sign character ("$") immediately followed by one or more digit characters. Each NAG then has a specific meaning and often a standard typographical representation. The meanings first defined stemmed from the use of specific typographic symbols when annotators were commenting upon chess games; most especially in Chess Informant [6] publications. The objective was to devise an alternative representation of these symbols which could be incorporated in the simple computer file format proposed as the PGN standard. This mechanism allowed often sophisticated typography to be expressed using the simple ASCII character set.

Since its inception there has been no attempt to further formalise or standardise the meaning of the undefined 116 NAGs although PGN editors, such as ChessPad, have variously used these higher glyphs.

NAG Groupings
NAG rangeClassification
$0 provided for the convenience of software designers as a placeholder value;

should not appear in PGN files and has no typographic representation

$1-$9 Move assessments
$10-$135 Positional Assessments
$136-$139 Time Pressure Commentaries
$140+ not defined

Standard NAGs

NAGMeaningSymbolUnicode [7] HTML [8] Name
$0null annotation
$1good move (traditional "!") see also Nunn Convention for alternate meanings !U+0021!single exclamation mark
$2poor move or mistake (traditional "?") (and Nunn Convention) ?U+003F?single question mark
$3very good or brilliant move (traditional "!!") (and Nunn Convention)U+203Cdouble exclamation mark
$4very poor move or blunder (traditional "??") (and Nunn Convention)U+2047double question mark
$5speculative or interesting move (traditional "!?") (and Nunn Convention)U+2049exclamation question mark
$6questionable or dubious move (traditional "?!") (and Nunn Convention)U+2048question mark and exclamation mark
$7forced move (all others lose quickly) or only moveU+25A1□white square
$8singular move (no reasonable alternatives)
$9worst move
$10drawish position or even=U+003D=equal sign
$11equal chances, quiet position
$12equal chances, active position
$13unclear positionU+221E∞infinity
$14White has a slight advantageU+2A72⩲plus sign above equals sign
$15Black has a slight advantageU+2A71⩱equals sign above plus sign
$16White has a moderate advantage±U+00B1±plus-minus sign
$17Black has a moderate advantageU+2213∓minus-or-plus sign
$18White has a decisive advantage+ −U+002B U+002D+ - [a] plus sign, hyphen-minus sign
$19Black has a decisive advantage− +U+002D U+002B - +hyphen-minus sign, plus sign
$20White has a crushing advantage (Black should resign)
$21Black has a crushing advantage (White should resign)
$22White is in zugzwangU+2A00⨀N-ary circled dot operator
$23Black is in zugzwang
$24White has a slight space advantage
$25Black has a slight space advantage
$26White has a moderate space advantageU+25CB○White circle
$27Black has a moderate space advantage
$28White has a decisive space advantage
$29Black has a decisive space advantage
$30White has a slight time (development) advantage
$31Black has a slight time (development) advantage
$32White has a moderate time (development) advantageU+27F3clockwise gapped circle arrow
$33Black has a moderate time (development) advantage
$34White has a decisive time (development) advantage
$35Black has a decisive time (development) advantage
$36White has the initiativeU+2191↑upwards arrow
$37Black has the initiative
$38White has a lasting initiative
$39Black has a lasting initiative
$40White has the attackU+2192→rightwards arrow
$41Black has the attack
$42White has insufficient compensation for material deficit
$43Black has insufficient compensation for material deficit
$44White has sufficient compensation for material deficitU+2BF9 [9] ⯹equals sign with infinity below
$45Black has sufficient compensation for material deficit
$46White has more than adequate compensation for material deficit
$47Black has more than adequate compensation for material deficit
$48White has a slight center control advantage
$49Black has a slight center control advantage
$50White has a moderate center control advantage
$51Black has a moderate center control advantage
$52White has a decisive center control advantage
$53Black has a decisive center control advantage
$54White has a slight kingside control advantage
$55Black has a slight kingside control advantage
$56White has a moderate kingside control advantage
$57Black has a moderate kingside control advantage
$58White has a decisive kingside control advantage
$59Black has a decisive kingside control advantage
$60White has a slight queenside control advantage
$61Black has a slight queenside control advantage
$62White has a moderate queenside control advantage
$63Black has a moderate queenside control advantage
$64White has a decisive queenside control advantage
$65Black has a decisive queenside control advantage
$66White has a vulnerable first rank
$67Black has a vulnerable first rank
$68White has a well protected first rank
$69Black has a well protected first rank
$70White has a poorly protected king
$71Black has a poorly protected king
$72White has a well protected king
$73Black has a well protected king
$74White has a poorly placed king
$75Black has a poorly placed king
$76White has a well placed king
$77Black has a well placed king
$78White has a very weak pawn structure
$79Black has a very weak pawn structure
$80White has a moderately weak pawn structure
$81Black has a moderately weak pawn structure
$82White has a moderately strong pawn structure
$83Black has a moderately strong pawn structure
$84White has a very strong pawn structure
$85Black has a very strong pawn structure
$86White has poor knight placement
$87Black has poor knight placement
$88White has good knight placement
$89Black has good knight placement
$90White has poor bishop placement
$91Black has poor bishop placement
$92White has good bishop placement
$93Black has good bishop placement
$94White has poor rook placement
$95Black has poor rook placement
$96White has good rook placement
$97Black has good rook placement
$98White has poor queen placement
$99Black has poor queen placement
$100White has good queen placement
$101Black has good queen placement
$102White has poor piece coordination
$103Black has poor piece coordination
$104White has good piece coordination
$105Black has good piece coordination
$106White has played the opening very poorly
$107Black has played the opening very poorly
$108White has played the opening poorly
$109Black has played the opening poorly
$110White has played the opening well
$111Black has played the opening well
$112White has played the opening very well
$113Black has played the opening very well
$114White has played the middlegame very poorly
$115Black has played the middlegame very poorly
$116White has played the middlegame poorly
$117Black has played the middlegame poorly
$118White has played the middlegame well
$119Black has played the middlegame well
$120White has played the middlegame very well
$121Black has played the middlegame very well
$122White has played the ending very poorly
$123Black has played the ending very poorly
$124White has played the ending poorly
$125Black has played the ending poorly
$126White has played the ending well
$127Black has played the ending well
$128White has played the ending very well
$129Black has played the ending very well
$130White has slight counterplay
$131Black has slight counterplay
$132White has moderate counterplayU+21C6⇆leftwards arrow over rightwards arrow
$133Black has moderate counterplay
$134White has decisive counterplay
$135Black has decisive counterplay
$136White has moderate time control pressure
$137Black has moderate time control pressure
$138White has severe time control pressure / zeitnotU+2A01⨁n-ary circle plus operator
$139Black has severe time control pressure / zeitnot

Non-standard NAGs

NAGUsed byMeaningSymbolUnicode [7] HTML [8] Name
$140ChessPad [10] With the idea...U+2206increment
$141ChessPad [10] Aimed against...U+2207nabla
$142ChessPad [10] Better is...U+2313⌓segment
$143ChessPad [10] Worse is...<=less than, equal to
$144ChessPad [10] Equivalent is...==equal to, equal to
$145ChessPad [10] Editorial commentRRcapital R, capital R
$146ChessPad [10] NoveltyNcapital N
$147–$219Not defined
$220ChessPad [10] Diagram⬒ (UI only)
$221ChessPad [10] Diagram (from Black)⬓ (UI only)
$222–$237Not defined
$238ChessPad [10] Space advantageU+25CB&cir;white circle
$239ChessPad [10] File (columns on the chessboard labeled a-h)U+21D4&hArr;left right double arrow
$240ChessPad [10] DiagonalU+21D7&neArr;north east double arrow
$241ChessPad [10] CentreU+229E&boxplus;squared plus
$242ChessPad [10] King-sideU+27EB&Rang;right double angle bracket
$243ChessPad [10] Queen-sideU+27EA&Lang;left double angle bracket
$244ChessPad [10] Weak pointU+2715multiplication x
$245ChessPad [10] EndingU+22A5&perp;up tack
$246ChessPad [10] Bishop pairCA Chess font: white square with white square to northeast
$247ChessPad [10] Opposite BishopsCA Chess font: white square with black square to northeast
$248ChessPad [10] Same BishopsCA Chess font: black square with black square to northeast
$249ChessPad [10] Connected pawnsU+2BFA [9] &#x2bfa;united symbol
$250ChessPad [10] Isolated pawnsU+2BFB [9] &#x2bfb;separated symbol
$251ChessPad [10] Doubled pawnsU+2BFC [9] &#x2bfc;doubled symbol
$252ChessPad [10] Passed pawnU+2BFD [9] &#x2bfd;passed symbol
$253ChessPad [10] Pawn majoritytext
$254ChessPad [10] WithU+221F [9] &#x221f;right angle
$255ChessPad [10] WithoutU+2BFE [9] &#x2bfe;reversed right angle

Notes on tables

  1. Some of the symbols are not rendered by some browsers
  2. The more exotic symbols used by Chess Informator [6] are often derived from common mathematical typographic symbols; their mathematical meaning rarely has any relevance to their chess meaning
  3. The entries in the Unicode column are, respectively, the decimal and hexadecimal reference for the character or symbol
  4. The entries in the HTML column are named HTML entities for representing the symbol or character; the Unicode numeric value can always be used where a specific entity does not exist. For example, the left right double arrow ($239) can be represented as either Unicode decimal &#8660; (⇔) or Unicode hexadecimal &#x21D4; (⇔) or HTML &hArr; (⇔). Unless explicitly noted, the Unicode representation can be interpreted as a default.

See also

Notes

  1. Unicode has a minus sign (U+002D, &minus;), but is seldom used

Related Research Articles

<span class="mw-page-title-main">Algebraic notation (chess)</span> Method to convey chess moves

Algebraic notation 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 board. It is now almost universally used by books, magazines, newspapers and software, and is the only form of notation recognized by FIDE, the international chess governing body.

The symbol # is known variously in English-speaking regions as the number sign, hash, or pound sign. The symbol has historically been used for a wide range of purposes including the designation of an ordinal number and as a ligatured abbreviation for pounds avoirdupois – having been derived from the now-rare .

In typography, a bullet or bullet point, , is a typographical symbol or glyph used to introduce items in a list. For example:
 Item 1
 Item 2
 Item 3

A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. They come in four main pairs of shapes, as given in the box to the right, which also gives their names, that vary between British and American English. "Brackets", without further qualification, are in British English the (...) marks and in American English the [...] marks.

OpenType is a format for scalable computer fonts. Derived from TrueType, it retains TrueType's basic structure but adds many intricate data structures for describing typographic behavior. OpenType is a registered trademark of Microsoft Corporation.

Forsyth–Edwards Notation (FEN) is a standard 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.

<span class="mw-page-title-main">Ligature (writing)</span> Glyph combining two or more letterforms

In writing and typography, a ligature occurs where two or more graphemes or letters are joined to form a single glyph. Examples are the characters ⟨æ⟩ and ⟨œ⟩ used in English and French, in which the letters ⟨a⟩ and ⟨e⟩ are joined for the first ligature and the letters ⟨o⟩ and ⟨e⟩ are joined for the second ligature. For stylistic and legibility reasons, ⟨f⟩ and ⟨i⟩ are often merged to create ⟨fi⟩ ; the same is true of ⟨s⟩ and ⟨t⟩ to create ⟨st⟩. The common ampersand, ⟨&⟩, developed from a ligature in which the handwritten Latin letters ⟨e⟩ and ⟨t⟩ were combined.

Chess notation systems are used to record either the moves made or the position of the pieces in a game of chess. Chess notation is used in chess literature, and by players keeping a record of an ongoing game. The earliest systems of notation used lengthy narratives to describe each move; these gradually evolved into more compact notation systems. Algebraic notation is now the accepted international standard, with several variants. Descriptive chess notation was used in English- and Spanish-language literature until the late 20th century, but is now obsolescent. Portable Game Notation (PGN) is a text file format based on English algebraic notation which can be processed by most chess software. Other notation systems include ICCF numeric notation, used for international correspondence chess, and systems for transmission using Morse code over telegraph or radio. The standard system for recording chess positions is Forsyth–Edwards Notation (FEN).

ICCF numeric notation is the official chess notation system of the International Correspondence Chess Federation. The system was devised for use in international correspondence chess to avoid the potential confusion of using algebraic notation, as the chess pieces have different abbreviations depending on language.

A Unicode block is one of several contiguous ranges of numeric character codes of the Unicode character set that are defined by the Unicode Consortium for administrative and documentation purposes. Typically, proposals such as the addition of new glyphs are discussed and evaluated by considering the relevant block or blocks as a whole.

<span class="mw-page-title-main">Scribal abbreviation</span> Abbreviations used by ancient and medieval scribes

Scribal abbreviations, or sigla, are abbreviations used by ancient and medieval scribes writing in various languages, including Latin, Greek, Old English and Old Norse.

When annotating chess games, commentators frequently use widely recognized annotation symbols. Question marks and exclamation points that denote a move as bad or good are ubiquitous in chess literature. Some publications intended for an international audience, such as the Chess Informant, have a wide range of additional symbols that transcend language barriers.

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.

X-FEN is an extension of Forsyth–Edwards Notation (FEN) introduced by Reinhard Scharnagl in 2003. It was designed to be able to represent all possible positions in Fischer random chess (FRC) and Capablanca random chess (CRC). It is fully backward compatible with FEN.

An overline, overscore, or overbar, is a typographical feature of a horizontal line drawn immediately above the text. In old mathematical notation, an overline was called a vinculum, a notation for grouping symbols which is expressed in modern notation by parentheses, though it persists for symbols under a radical sign. The original use in Ancient Greek was to indicate compositions of Greek letters as Greek numerals. In Latin, it indicates Roman numerals multiplied by a thousand and it forms medieval abbreviations (sigla). Marking one or more words with a continuous line above the characters is sometimes called overstriking, though overstriking generally refers to printing one character on top of an already-printed character.

Unicode equivalence is the specification by the Unicode character encoding standard that some sequences of code points represent essentially the same character. This feature was introduced in the standard to allow compatibility with pre-existing standard character sets, which often included similar or identical characters.

<span class="mw-page-title-main">Universal Character Set characters</span> Complete list of the characters available on most computers

The Unicode Consortium and the ISO/IEC JTC 1/SC 2/WG 2 jointly collaborate on the list of the characters in the Universal Coded Character Set. The Universal Coded Character Set, most commonly called the Universal Character Set, is an international standard to map characters, discrete symbols used in natural language, mathematics, music, and other domains, to unique machine-readable data values. By creating this mapping, the UCS enables computer software vendors to interoperate, and transmit—interchange—UCS-encoded text strings from one to another. Because it is a universal map, it can be used to represent multiple languages at the same time. This avoids the confusion of using multiple legacy character encodings, which can result in the same sequence of codes having multiple interpretations depending on the character encoding in use, resulting in mojibake if the wrong one is chosen.

Many Unicode characters are used to control the interpretation or display of text, but these characters themselves have no visual or spatial representation. For example, the null character is used in C-programming application environments to indicate the end of a string of characters. In this way, these programs only require a single starting memory address for a string, since the string ends once the program reads the null character.

The Unicode Standard assigns various properties to each Unicode character and code point.

References

  1. "Standard: Portable Game Notation Specification and Implementation Guide". Internet Archive. 12 March 1994. Retrieved 25 July 2020. The page linking to the document is here.
  2. The Rise of Internet Chess, Mark Weeks' chess pages
  3. For example, the PGN generated by lichess for the online match between grandmasters Pavel Smirnov and Andrew Tang (2020) lists a URL in the site field.
  4. Burgess, Graham (2000) [1997], The Mammoth Book of Chess, Carroll & Graph, p. 517, ISBN   0-7867-0725-9, The main differences from standard Algebraic are that there is both a dot and a space after each move number, and an upper case "O" is used instead of a zero in the notation for castling.
  5. "Formal PGN File Specification:section 8.2.4 defines 256 NAGs while section 10 identifies first 140 NAGs". 1994. Retrieved 1 Oct 2016.
  6. 1 2 "Chess Informant: System of Signs". Archived from the original on 2017-01-01.Uses FigurineCB webfont.
  7. 1 2 Wood, Alan. "Unicode and multilingual support in HTML, fonts, Web browsers and other applications". www.alanwood.net.
  8. 1 2 "Character Entity Reference Chart". HTML5 (W3C).
  9. 1 2 3 4 5 6 7 "Miscellaneous Symbols and Arrows" (PDF). Character Code Charts (PDF). The Unicode Consortium. 2022. Subsection "Symbols used in chess notation".
  10. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 "ChessPad: a PGN editor". www.wmlsoftware.com.

Sources