Difference between revisions of "Forsyth-Edwards Notation"

From Chessprogramming wiki
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 85: Line 85:
  
 
==X-FEN==
 
==X-FEN==
The earlier [https://en.wikipedia.org/wiki/X-FEN X-FEN] extension was introduced by [[Reinhard Scharnagl]] in 2003, and covers not only [[Chess960]] but also 10x8 variants. Its author dogmatically claimed upward compatibility with standard chess <ref>[https://www.stmintz.com/ccc/index.php?id=437213 Why to use compatible X-FEN (in Chess960)] by [[Reinhard Scharnagl]], [[CCC]], July 17, 2005</ref>, still using the '''KQkq''' [[Castling Rights|castling right]] characters for all Chess960 positions where the king is between both rooks - and the [[Files|file characters]] otherwise. Further, X-FEN introduced a changed [[En passant|en passant]] target square semantic, which is only specified after a double pawn push was made beside an opponent pawn that might capture en passant if legal, that is not leaving its king in check.  
+
The earlier [https://en.wikipedia.org/wiki/X-FEN X-FEN] extension was introduced by [[Reinhard Scharnagl]] in 2003, and covers not only [[Chess960]] but also 10x8 variants. Its author dogmatically claimed upward compatibility with standard chess <ref>[https://www.stmintz.com/ccc/index.php?id=437213 Why to use compatible X-FEN (in Chess960)] by [[Reinhard Scharnagl]], [[CCC]], July 17, 2005</ref>, still using the '''KQkq''' [[Castling Rights|castling right]] characters for all Chess960 positions. Further, X-FEN introduced a changed [[En passant|en passant]] target square semantic, which is only specified after a double pawn push was made beside an opponent pawn that might capture en passant if legal, that is not leaving its king in check.  
  
 
=See also=  
 
=See also=  
Line 91: Line 91:
 
* [[Forsyth-Edwards Expanded Notation]] (FEEN)
 
* [[Forsyth-Edwards Expanded Notation]] (FEEN)
 
* [[Portable Game Notation]] (PGN)
 
* [[Portable Game Notation]] (PGN)
 +
* [[BMI2#FEN Compression|BMI2 FEN Compression]]
  
 
=Forum Posts=  
 
=Forum Posts=  
 +
==1993 ...==
 +
* [https://groups.google.com/d/msg/rec.games.chess/MkLV6dIwGU4/GfbtTyR6o6sJ Revised PGN standard available] by [[Steven Edwards]], [[Computer Chess Forums|rgc]], December 20, 1993 » [[Portable Game Notation]]
 +
* [https://www.stmintz.com/ccc/index.php?id=53266 Full definition for FEN] by [[Dann Corbit]], [[CCC]], May 27, 1999
 
==2000 ...==
 
==2000 ...==
 
* [https://www.stmintz.com/ccc/index.php?id=138460 File name extensions] by [[Leen Ammeraal]], [[CCC]], November 14, 2000  
 
* [https://www.stmintz.com/ccc/index.php?id=138460 File name extensions] by [[Leen Ammeraal]], [[CCC]], November 14, 2000  
Line 101: Line 105:
 
* [https://www.stmintz.com/ccc/index.php?id=439792 Chess960: X-FEN rules international] by [[Reinhard Scharnagl]], [[CCC]], August 03, 2005
 
* [https://www.stmintz.com/ccc/index.php?id=439792 Chess960: X-FEN rules international] by [[Reinhard Scharnagl]], [[CCC]], August 03, 2005
 
* [https://www.stmintz.com/ccc/index.php?id=439995 contradicting FEN and SMK-FEN] by [[Reinhard Scharnagl]], [[CCC]], August 04, 2005
 
* [https://www.stmintz.com/ccc/index.php?id=439995 contradicting FEN and SMK-FEN] by [[Reinhard Scharnagl]], [[CCC]], August 04, 2005
 +
* [https://www.stmintz.com/ccc/index.php?id=459898 Chess960: Arena castle vs X-FEN castle] by [[Matthias Gemuh]], [[CCC]], November 05, 2005
 
* [http://www.talkchess.com/forum/viewtopic.php?t=13923 fen to fen functions] by [[Uri Blass]], [[CCC]], May 21, 2007
 
* [http://www.talkchess.com/forum/viewtopic.php?t=13923 fen to fen functions] by [[Uri Blass]], [[CCC]], May 21, 2007
 
==2010 ...==
 
==2010 ...==
Line 119: Line 124:
 
==2020 ...==
 
==2020 ...==
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=73552 FEN and 3rd repetition rule. No information?] by [[Luis Babboni]], [[CCC]], April 03, 2020 » [[Repetitions]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=73552 FEN and 3rd repetition rule. No information?] by [[Luis Babboni]], [[CCC]], April 03, 2020 » [[Repetitions]]
 
+
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76892 FEN compression] by lucasart, [[CCC]], March 17, 2021 » [[BMI2#FEN Compression|FEN Compression]], [[NNUE#Training|NNUE Training]]
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79627 Required fields in Forsyth-Edwards Notation (FEN)] by [[Niels Abildskov]], [[CCC]], April 02, 2022
 +
 
=External Links=  
 
=External Links=  
 
* [https://en.wikipedia.org/wiki/Forsyth-Edwards_Notation Forsyth-Edwards Notation from Wikipedia]
 
* [https://en.wikipedia.org/wiki/Forsyth-Edwards_Notation Forsyth-Edwards Notation from Wikipedia]
Line 127: Line 134:
 
: [http://www.gilith.com/software/fen2img/ fen2img Chess Diagram Maker] by [[Joe Leslie-Hurd]]
 
: [http://www.gilith.com/software/fen2img/ fen2img Chess Diagram Maker] by [[Joe Leslie-Hurd]]
 
* [http://webchess.freehostia.com/diag/index.php Chess Diagram Generator]
 
* [http://webchess.freehostia.com/diag/index.php Chess Diagram Generator]
 +
* [https://github.com/bagaturchess/ChessBoardScanner GitHub - bagaturchess/ChessBoardScanner: Java based Chess Board Scanner, which converts 2D chess board image into a machine readable format a.k.a. Forsyth–Edwards Notation (FEN)] by [[Krasimir Topchiyski]]
 
* [http://chessforeva.blogspot.de/2009/10/3d-chess-diagram-from-fen.html Chessforeva: 3D chess diagram from FEN] » [[3D Graphics Board]]
 
* [http://chessforeva.blogspot.de/2009/10/3d-chess-diagram-from-fen.html Chessforeva: 3D chess diagram from FEN] » [[3D Graphics Board]]
 
* <span id="FEN2EPS"></span>[http://fen2eps.sourceforge.net/ Fen2eps] by [[Dirk Baechle]] <ref>[https://en.wikipedia.org/wiki/Encapsulated_PostScript Encapsulated PostScript from Wikipedia]</ref>
 
* <span id="FEN2EPS"></span>[http://fen2eps.sourceforge.net/ Fen2eps] by [[Dirk Baechle]] <ref>[https://en.wikipedia.org/wiki/Encapsulated_PostScript Encapsulated PostScript from Wikipedia]</ref>

Latest revision as of 08:47, 5 April 2022

Home * Chess * Position * Forsyth-Edwards Notation

Forsyth-Edwards Notation (FEN) describes a Chess Position. It is an one-line ASCII-string. FEN is based on a system created by Scotsman David Forsyth in the 19th century. Steven Edwards specified the FEN standard for computer chess applications as part of the Portable Game Notation [1] .

FEN Syntax

One FEN string or record consists of six fields separated by a space character. The first four fields of the FEN specification are the same as the first four fields of the EPD specification.

Terminal and nonterminal symbols of a variant of BNF below are embedded in ' ' resp. < >.

<FEN> ::=  <Piece Placement>
       ' ' <Side to move>
       ' ' <Castling ability>
       ' ' <En passant target square>
       ' ' <Halfmove clock>
       ' ' <Fullmove counter>

Piece Placement

The Piece Placement is determined rank by rank in big-endian order, that is starting at the 8th rank down to the first rank. Each rank is separated by the terminal symbol '/' (slash). One rank, scans piece placement in little-endian file-order from the A to H.

A decimal digit counts consecutive empty squares, the pieces are identified by a single letter from standard English names for chess pieces as used in the Algebraic Chess Notation. Uppercase letters are for white pieces, lowercase letters for black pieces.

<Piece Placement> ::= <rank8>'/'<rank7>'/'<rank6>'/'<rank5>'/'<rank4>'/'<rank3>'/'<rank2>'/'<rank1>
<ranki>       ::= [<digit17>]<piece> {[<digit17>]<piece>} [<digit17>] | '8'
<piece>       ::= <white Piece> | <black Piece>
<digit17>     ::= '1' | '2' | '3' | '4' | '5' | '6' | '7'
<white Piece> ::= 'P' | 'N' | 'B' | 'R' | 'Q' | 'K'
<black Piece> ::= 'p' | 'n' | 'b' | 'r' | 'q' | 'k'

Side to move

Side to move is one lowercase letter for either White ('w') or Black ('b').

<Side to move> ::= {'w' | 'b'}

Castling ability

If neither side can castle, the symbol '-' is used, otherwise each of four individual castling rights for king and queen castling for both sides are indicated by a sequence of one to four letters.

<Castling ability> ::= '-' | ['K'] ['Q'] ['k'] ['q'] (1..4)

En passant target square

The en passant target square is specified after a double push of a pawn, no matter whether an en passant capture is really possible or not [2] [3] [4] . Other moves than double pawn pushes imply the symbol '-' for this FEN field.

<En passant target square> ::= '-' | <epsquare>
<epsquare>   ::= <fileLetter> <eprank>
<fileLetter> ::= 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h'
<eprank>     ::= '3' | '6'

Halfmove Clock

The halfmove clock specifies a decimal number of half moves with respect to the 50 move draw rule. It is reset to zero after a capture or a pawn move and incremented otherwise.

<Halfmove Clock> ::= <digit> {<digit>}
<digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Fullmove counter

The number of the full moves in a game. It starts at 1, and is incremented after each Black's move.

<Fullmove counter> ::= <digit19> {<digit>}
<digit19> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
<digit>   ::= '0' | <digit19>

Samples

FEN strings of Starting Position and after 1.e4 c5 2.Nf3:

    
    
    
    
    
    
    
    


        
        
        
        


♜♞♝♛♚♝♞♜
♟♟♟♟♟♟♟♟
        
        
        
        
♙♙♙♙♙♙♙♙
♖♘♗♕♔♗♘♖
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
    
    
    
    
    
    
    
    


        
        
       
        
 

♜♞♝♛♚♝♞♜
♟♟♟♟♟♟♟♟
        
        
    ♙   
        
♙♙♙♙ ♙♙♙
♖♘♗♕♔♗♘♖
1.e4
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
    
    
    
    
    
    
    
    

 
        
       
       
        
 

♜♞♝♛♚♝♞♜
♟♟ ♟♟♟♟♟
        
  ♟     
    ♙   
        
♙♙♙♙ ♙♙♙
♖♘♗♕♔♗♘♖
1.e4 c5
rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2
    
    
    
    
    
    
    
    

 
        
       
       
       
 
 
♜♞♝♛♚♝♞♜
♟♟ ♟♟♟♟♟
        
  ♟     
    ♙   
     ♘  
♙♙♙♙ ♙♙♙
♖♘♗♕♔♗ ♖
1.e4 c5 2.Nf3
rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2 

Chess960

Shredder-FEN

Shredder-FEN or SMK-FEN is an extension of FEN covering Chess960, introduced by Shredder author Stefan Meyer-Kahlen (SMK) in 2005. Shredder-FEN uses different castling right characters, that is instead of KQkq, upper case and lower case file characters of the affected rooks for white and black castling rights, and became a de facto standard supported by most GUIs and protocols.

X-FEN

The earlier X-FEN extension was introduced by Reinhard Scharnagl in 2003, and covers not only Chess960 but also 10x8 variants. Its author dogmatically claimed upward compatibility with standard chess [5], still using the KQkq castling right characters for all Chess960 positions. Further, X-FEN introduced a changed en passant target square semantic, which is only specified after a double pawn push was made beside an opponent pawn that might capture en passant if legal, that is not leaving its king in check.

See also

Forum Posts

1993 ...

2000 ...

2005 ...

2010 ...

2015 ...

2020 ...

External Links

fen2img Chess Diagram Maker by Joe Leslie-Hurd

References

Up one Level