Is there a Mathematica chess package? I'm trying to generate GIFs from chess PGNs. Additionally, I like to try some chess algorithms against a chess engine and watch the game and run statistical analysis on hundreds of games. I don't want to write everything from scratch but I don't know where to search for third party Mathematica packages.

  • 2
    $\begingroup$ A chess related visualization can be found here. Packages can be found here, but there doesn't seem to be any chess package there. $\endgroup$
    – C. E.
    Commented Jul 31, 2017 at 22:41
  • 2
    $\begingroup$ @C.E. There now exists a chess package at packagedata.net/index.php/links/search/365/Chess $\endgroup$
    – lirtosiast
    Commented Jul 2, 2019 at 5:59

1 Answer 1


Wolfram Language 13.2 has a built-in preliminary support for chess. You can import PGN files and FEN strings, render positions as graphics, process game metadata, display dynamic game summary and more.

Generating a GIF of a chess game from PGN file is straightforward:

In[1]:= positions = Import["ExampleData/sample.pgn", {"PositionRenderingList", 1}];

In[2]:= Export["game.gif", positions]

Out[2]= "game.gif"

By default chess positions are rendered to a Graphics expression which looks like this

white and gray chessboard

If you don't like the default white and gray chessboard or you want to flip the board there are options for customization, e.g.:

flipped board with different square colors

You can also import game metadata with dates, times and famous players being automatically interpreted as corresponding Wolfram Language expressions or entities:

import PGN metadata

For more information see:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.