Forsyth–Edwards Notation
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.
FEN is based on a system developed by Scottish newspaper journalist David Forsyth. Forsyth's system became popular in the 19th century; Steven J. Edwards extended it to support use by computers. FEN is defined[2] in the "Portable Game Notation Specification and Implementation Guide".[1] In the Portable Game Notation for chess games, FEN is used to define initial positions other than the standard one.[3] 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.
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 have the file extension ".fen".[4]
A FEN record contains six fields. The separator between fields is a space. The fields are:[5]
- Piece placement (from White's perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file "a" through file "h". Following the Standard Algebraic Notation (SAN), each piece is identified by a single letter taken from the standard English names (pawn = "P", knight = "N", bishop = "B", rook = "R", queen = "Q" and king = "K"). White pieces are designated using upper-case letters ("PNBRQK") while black pieces use lowercase ("pnbrqk"). Empty squares are noted using digits 1 through 8 (the number of empty squares), and "/" separates ranks.
- Active color. "w" means White moves next, "b" means Black moves next.
- Castling availability. If neither side can castle, this is "-". Otherwise, this has one or more letters: "K" (White can castle kingside), "Q" (White can castle queenside), "k" (Black can castle kingside), and/or "q" (Black can castle queenside). A move that temporarily prevents castling does not negate this notation.
- En passant target square in algebraic notation. If there's no en passant target square, this is "-". If a pawn has just made a two-square move, this is the position "behind" the pawn. This is recorded regardless of whether there is a pawn in position to make an en passant capture.[6]
- Halfmove clock: This is the number of halfmoves since the last capture or pawn advance. This is used to determine if a draw can be claimed under the fifty-move rule.
- Fullmove number: The number of the full move. It starts at 1, and is incremented after Black's move.
Examples
The following example is from the FEN specification:[7]
Here's 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 critical 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, in Chess960, the initial position is not completely randomized, but follows some rules, which are bishops are in opposite colors, the King always starts between the Rooks, so that castling both sides is an option [9].
However, the FEN castling availability encoding (KQkq) is inadequate for positions in which there are two rooks on the same side of the king on the back rank. It is ambiguous which rook is still available for castling 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. For the traditional setup, Shredder-FEN would use AHah instead of KQkq.
Another solution is offered by X-FEN, which offers more backward compatibility than does Shredder-FEN, but at the cost of more complexity.
References
- "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.
- Section "16.1: FEN" in "Portable Game Notation Specification and Implementation Guide"[1]
- Sections "9.7.1: Tag: SetUp" and "9.7.2: Tag: FEN" in "Portable Game Notation Specification and Implementation Guide"[1]
- Last paragraph in section "16.1: FEN" in "Portable Game Notation Specification and Implementation Guide"[1]
- Sections 16.1.3.1 to 16.1.3.6: in "Portable Game Notation Specification and Implementation Guide"[1]
- Section "16.2.3.4: En passant target square" in "Portable Game Notation Specification and Implementation Guide"[1]
- Section "16.1.4: Examples" in "Portable Game Notation Specification and Implementation Guide"[1]
- "FIDE Laws of Chess taking effect from 1 January 2018". FIDE. Retrieved 25 July 2020.
- "II.2 Starting-position requirements" in "Guidelines II. Chess960 Rules" in the FIDE Laws of Chess[8]