Function Repository Resource:

ShowChessPosition

Source Notebook

Display a chess position from FEN (Forsyth–Edwards Notation)

Contributed by: Lucien Grondin

ResourceFunction["ShowChessPosition"]["fen"]

displays the chess position fen as described according to Forsyth–Edwards Notation.

ResourceFunction["ShowChessPosition"][]

displays the standard startup position.

Details

The default value for fen is the standard startup chess position. This is shown using ResourceFunction["ShowChessPosition"][].
The produced diagram is a Grid of unicode characters.
All pieces are represented as expressions, not strings. For instance the white king is ♔, not "♔". This might be an issue in a context when these expressions are defined.

Examples

Basic Examples (2) 

Show the startup position:

In[1]:=
ResourceFunction["ShowChessPosition"][]
Out[1]=

Show a game after a few moves:

In[2]:=
ResourceFunction[
 "ShowChessPosition"]@"rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 0 1"
Out[2]=

Properties and Relations (1) 

The commentary characters at the end do not affect the display:

In[3]:=
ResourceFunction[
 "ShowChessPosition"]@"rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR"
Out[3]=
In[4]:=
ResourceFunction[
 "ShowChessPosition"]@"rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 0 1"
Out[4]=

Publisher

Lucien Grondin

Version History

  • 1.0.0 – 05 February 2021

Related Resources

License Information