pgn4web mostly supports the PGN (Portable Game Notation) standard for chess games notation. For more information about the PGN standard you can read the PGN entry in wikipedia.
The general design principle is for pgn4web to try as much as possible to automatically recover from minor errors in the PGN data and only stop the game replay after unrecoverable errors.
Following PGN tags are parsed and used: Event
, Site
, Date
, Round
, White
, Black
, Result
, SetUp
and FEN
. The PGN tags WhiteClock
and BlackClock
are also used, but only for live game broadcasting. A customization function is available to parse any other header tags.
pgn4web manages common mistakes in PGN files, trying as much as possible to avoid triggering exceptions. For instance, following exceptions are tolerated:
FEN
tag without SetUp
tag: SetUp
assumed set to 1
if FEN
is present ?
Failure to load PGN data, incorrect PGN games or incorrect FEN strings generate exceptions: pgn4web signals those by flashing unintrusively the chessboard at regular intervals. Please refer to the debugging page for more information and for an example.
Ambiguous moves are errors in the PGN data where not enough information is provided to determine the intended unique move. For example in the following sequence the move 3. Nd2 is ambiguous because both the knights from b1 and f3 could move to d2:
1. d4 d5 2. Nf3 Nf6 3. Nd2
The ambiguous move error 3. Nd2 should be replaced by either 3. Nbd2 or 3. Nfd2.
When encountering an ambiguous move pgn4web first flags the error with an alert message; rather than stopping the game replay after the error, pgn4web then guesses which of the possible moves was intended and continues the replay; if the guess was correct, the game will replay in full; if the guess was not correct, it's possible that an invalid move alert will follow later and stop the game replay; it should be noted that the game continuation after an ambiguous move alert it's never fully reliable.
Special characters, such as symbols (such as ½ ¿ ß) and accented letters (such as â è õ ü), can appear in PGN files as comments or as part of the header values; in order for pgn4web to display those characters correctly, the PGN file should be saved in unicode UTF-8 format.
If you are forced to use PGN files encoded in a different format, you might try patching manually the pgn4web.js file, searching for "// patch: pgn encoding" and following instructions.
A frequently asked question is how to enter a chess position without necessarily having the full game text. pgn4web supports the PGN tag FEN
that allows modifying the starting position by providing a FEN (Forsyth-Edwards Notation) string; for example:
[Event "white to move"] [FEN "rn2r1k1/ppq2pb1/2pp2pp/8/2PQn1b1/1PN2NP1/PB3PBP/3RR1K1 w - - 0 17"] 17.Qxg7 Kxg7 18.Nd5 Kf8 19.Nxc7
pgn4web supports Chess960 (a.k.a. Fischer random chess) by understanding both the X-FEN and the Shredder-FEN extensions to the FEN notation; pgn4web generates X-FEN strings when clicking the associated shortcut square.
See this example showing the 2006 rapid Chess960 World Championship.
Notable exceptions and limitations of pgn4web PGN support:
pgn4web also follows a set of proposed extensions to the PGN standard, more specifically:
[%clk 1:59:58]
tag in the PGN comment section as the clock time after each move [WhiteClock "2:00:00"]
and [BlackClock "2:00:00"]
as the clock times at the beginning of the game [Clock "W/1:59:59"]
as the clock time of the running clock customPgnCommentTag()
pgn4web supports PGN null moves in the --
notation (used by a number of chess tools like scid and chessbase), such as in 1. e4 -- 2. d4
Note the equivalent <>
nullmove notation is currently not supported by pgn4web.
pgn4web supports PGN continuations (defined as variations where the last move played before the variation is not taken back prior to the start of the variation moves) in the (*
notation, such as in 1. e4 (* 1... d5 2. exd5) 2... e5
Please email me for review any PGN file that pgn4web fails parsing correctly.
Wiki: Example_Chess960
Wiki: HowTo_Debugging
Wiki: Index
Wiki: Translating