CITE THIS NOTEBOOK: The Forsyth-Edwards-Notation (FEN) with Chess Alpha font by Oliver Seipel. Wolfram Community JAN 5 2023.
This is a new feature in Version 13.2:
In[]:=
chessposition=First[ImportString["5n2/3nrpk1/1qBp2p1/p2P3p/1rp1PP2/2N4P/1P2RQP1/4R2K w - - 4 69","FEN"]]
Out[]=
And here with hatchfilling the dark squares:
In[]:=
Image[Graphics[{{HatchFilling[Pi/4,1/2,9/2],GrayLevel[0.5],Table[If[EvenQ[x+y],Rectangle[{x,y}+1/2]],{x,0,7},{y,0,7}]},Last@First@chessposition},Frame->True,FrameTicks{{Range[8],None},{{Range[8],FromCharacterCode/@Range[97,104]},None}},FrameTicksStyleDirective[Bold,16]]]
Out[]=
But what, if you don’t like these chess pieces?
First you have to install “Chess Alpha” font.
https://www.dafont.com/chess-alpha.font
Other chess fonts have usually different character replacements.
https://www.dafont.com/chess-alpha.font
Other chess fonts have usually different character replacements.
In[]:=
FENtoTextCell[fen_,size_:24]:=With[{c={"K","Q","B","R","P"}},With[{c0=Join[ToLowerCase[c],{"N","n"}],c1={"L","W","N","T","O","H","J"}},With[{odd=Join[Thread[c0c1],{" ""+"}],even=Join[Thread[c0ToLowerCase[c1]],Thread[cToLowerCase[c]],{" "FromCharacterCode[31]}]},CellPrint[TextCell[StringRiffle[Map[StringJoin,MapIndexed[#/.If[OddQ[Plus@@#2],odd,even]&,Characters[StringReplace[StringExtract[StringExtract[fen,1],"/"All],a:DigitCharacterStringRepeat[" ",ToExpression[a]]]],{2}]],"\n"],"Text",FontFamily"Chess Alpha",size,LineSpacing{1,0}]]]]]
In[]:=
FENtoTextCell["5n2/3nrpk1/1qBp2p1/p2P3p/1rp1PP2/2N4P/1P2RQP1/4R2K w - - 4 69",48]
The output was converted into a Bitmap (Cell ⊳ Convert To ⊳ Bitmap).
This is scalable and can be seen on computers not having the Chess Alpha font.
This is scalable and can be seen on computers not having the Chess Alpha font.