showChessPosition[fen_String:"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"]:=GridPartitionPartitionRiffleCharactersStringReplaceStringExtract[fen,1],"/""","K""♔","Q""♕","R""♖","B""♗","N""♘","P""♙","k""♚","q""♛","r""♜","b""♝","n""♞","p""♟",n_/;DigitQ[n]StringJoin@ConstantArray[" ",ToExpression[n]],Flatten@Table[If[EvenQ[i+j],White,LightGray],{i,8},{j,8}],2/.{p_String,c:White|LightGray}Item[p,Backgroundc],8,AlignmentCenter,FrameTrue,Spacings0.1+{0,.2}
In[]:=
showChessPosition@"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
Out[]=
♜ | ♞ | ♝ | ♛ | ♚ | ♝ | ♞ | ♜ |
♟ | ♟ | ♟ | ♟ | ♟ | ♟ | ♟ | ♟ |
♙ | ♙ | ♙ | ♙ | ♙ | ♙ | ♙ | ♙ |
♖ | ♘ | ♗ | ♕ | ♔ | ♗ | ♘ | ♖ |
In[]:=
showChessPosition@"rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 0 1"
Out[]=
♜ | ♞ | ♝ | ♚ | ♝ | ♞ | ♜ | |
♟ | ♟ | ♟ | ♟ | ♟ | ♟ | ♟ | |
♟ | |||||||
♙ | ♙ | ♛ | |||||
♙ | ♙ | ♙ | ♙ | ♙ | ♙ | ||
♖ | ♘ | ♗ | ♕ | ♔ | ♗ | ♘ | ♖ |
In[]:=
Export["fool's mate.svg",%,"SVG"]
Out[]=
fool's mate.svg