Forsyth–Edwards Notation
Notation for describing a chess game position
From Wikipedia, the free encyclopedia
History
Forsyth notation
FEN is based on a system known as Forsyth notation, developed in 1883 by Scottish newspaper journalist David Forsyth. His system became popular in the 19th century.[1] Unlike modern FEN, this notation, designed as a short-hand for writing out the position of every piece on the board, was only interested in capturing the position of the pieces, and not the other metadata such as which player is to move, castling availability, and move count, which presumably would have been written out in full or implied by context.
The notation was first proposed by Forsyth in the Glasgow Weekly Herald on February 2, 1883.[2] Forsyth wrote:
When a game of Chess requires to be adjourned, or when an interesting position occurs which one would like to preserve for subsequent examination, it can be noted in either of two ways—1st, by a blank diagram; or 2nd, by stating with reference to the squares on the board the position of each individual piece and pawn. The latter method is very tedious, and the former is only available when blank digrams are at hand. Since beginning to learn Chess, I have used a system (so far as I know entirely original), by which a position can be recorded very expeditiously, the only necessary material being a pencil and a scrap of paper the size of a postage stamp.
Forsyth's original system used one line of written text for each rank of the board. Each piece was denoted by a letter or letters: K, Q, R, B, P, with the knight being denoted with "Kt", which was the convention at the time. Black pieces were denoted with an underline. Empty squares were denoted with a "0", with a series of adjacent empty squares being denoted with that number (e.g. "5" denoted a sequence of five empty squares on a row). Oddly, this meant that one would use "0" for one square and "2" for two squares, with no use for the digit "1".
Forsyth gives an example (with the accompanying text "after Black's 40th move")[note 1]:
0 R 6
5 P P 0
R 0 R 4 P
0 R 0 P P 3
2 P K Q P P 0
7 P
0 P 6
2 K 5
denoting a position with a black rook on b8, two black pawns on f7 and g7, white rooks on a6 and d6 and a black pawn on h6, and so on. The equivalent position in modern FEN is:
1r6/5pp1/R1R4p/1r1pP3/2pkQPP1/7P/1P6/2K5 w - - 0 41
By 1897, the notation appears to have evolved to more resemble the modern syntax, with the following example given in a biography of Forsyth in The Chess Bouquet[2][note 2]:
1 B 6, 2 kt 5, p 1 Kt 1 P 2 R, P 1 K 3 Kt 1, 4 P k 2, 1 Q 2 p 2 p, 6 kt P, 1 B 4 R 1
In this version, the position is written all on one line, with commas to separate ranks, the "0" denoting a single empty square has been replaced with a "1", and black pieces are denoted with lowercase letters rather than underlines. The equivalent position in modern FEN is:
1B6/2n5/p1N1P2R/P1K3N1/4Pk2/1Q2p2p/6nP/1B4R1 w - - 0 1
Extension by Edwards
In 1993, Steven J. Edwards extended Forsyth's system to support its use by computers, as part of the Portable Game Notation standard[3]. The most commonly cited version was published on March 12, 1994[4]. The standard states that:
The original Forsyth standard has been slightly extended for use with chess software by Steven Edwards with assistance from commentators on the Internet. This new standard, FEN, was first implemented in Edwards' SAN Kit.
Edwards' format is explicitly specified as an ASCII text format, intended to be parsed by computer software. He removed the spaces in between squares, replaced the commas (separating ranks) with slashes, changed the knight from "Kt" to "N" (reflecting modern algebraic notation), and added additional metadata fields such as which player is to move, castling availability, and more, as described below.
Usage
FEN is defined[5] in the "Portable Game Notation Specification and Implementation Guide".[4]
In the Portable Game Notation for chess games, FEN is used to define initial positions other than the standard one.[6]
FEN does not provide sufficient information to decide whether a draw by threefold repetition may be legally claimed or a draw offer may be accepted; for that, a different format such as Extended Position Description is needed.[clarification needed][citation needed]
Definition
A FEN record defines a particular game position, all in one text line and using only the ASCII character set. A text file with only FEN data records should use the filename extension .fen.[7]
A FEN record contains six fields, each separated by a space. The fields are as follows:[8]
- Piece placement data: Each rank is described, starting with rank 8 and ending with rank 1, with a "/" between each one; within each rank, the contents of the squares are described in order from the a-file to the h-file. Each piece is identified by a single letter taken from the standard English names in algebraic notation (pawn = "P", knight = "N", bishop = "B", rook = "R", queen = "Q", and king = "K"). White pieces are designated using uppercase letters ("PNBRQK"), while black pieces use lowercase letters ("pnbrqk"). A set of one or more consecutive empty squares within a rank is denoted by a digit from "1" to "8", corresponding to the number of squares.
- Active color: "w" means that White is to move; "b" means that Black is to move.
- Castling availability: If neither side has the ability to castle, this field uses the character "-". Otherwise, this field contains one or more letters: "K" if White can castle kingside, "Q" if White can castle queenside, "k" if Black can castle kingside, and "q" if Black can castle queenside. A situation that temporarily prevents castling does not prevent the use of this notation.
- En passant target square: This is a square over which a pawn has just passed while moving two squares; it is given in algebraic notation. If there is no en passant target square, this field uses the character "-". This is recorded regardless of whether there is a pawn in position to capture en passant.[9] An updated version of the spec has since made it so the target square is recorded only if a legal en passant capture is possible, but the old version of the standard is the one most commonly used.[10][11]
- Halfmove clock: The number of halfmoves since the last capture or pawn advance, used for the fifty-move rule.[12]
- Fullmove number: The number of the full moves. It starts at 1 and is incremented after Black's move.[citation needed]
Examples
The following example is from the FEN specification:[13]
Here is the FEN for the starting position:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
And after the move 1.e4:
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
And then after 1...c5:
rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2
And then after 2.Nf3:
rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2
FEN adjustment for chess variants like Chess960
FEN is crucial for recording games in chess variants such as Chess960 (also known as Fischer Random Chess), where the initial position is not necessarily the traditional initial position. However, the FEN castling availability encoding (KQkq) is inadequate when both rooks are on the same side of the king on the back rank (as a result of one rook having moved, or in a form of randomized chess that allows it in a starting position): if either rook is still available for castling, it would be ambiguous which rook this is without knowing their initial positions. The solution implemented by chess engines like Shredder and Fritz_9 is to use the letters of the columns on which the rooks began the game. This scheme is sometimes called Shredder-FEN.[14]
For the traditional setup, Shredder-FEN would use AHah instead of KQkq.[citation needed]
Another solution is offered by X-FEN, which offers more backward compatibility than Shredder-FEN does, but at the cost of more complexity.[citation needed]