This code uses a chess game's Portable Game Notation (PGN) to produce move-diagrams as shown below (produced from Viswanathan Anand's 1997 brilliancy against Joel Lautier in Biel):
It is written in Python 3, using the chess
package.
You need Python's chess
package, so before running the scripts in this repository, make sure to type in any of the following commands in your command line/powershell:
pip install chess
pip3 install chess
Unfortunately, this package is not part of Anaconda's registry of packages so conda
won't work here.
After you have the chess
package set up, clone this repository into a directory of your choice using
git clone https://github.com/sreekar-voleti/chess-art.git
-
Download the PGN (.pgn file) for any game you want to turn into art (I have only tried this with games from lichess and chess.com but in principle any valid PGN file should work), and place it in the
chess-art/PGNFiles/
directory. -
Go into
inputs.py
and change thefile_name
to the name of the PGN file (just the name of the file, no need for any directory specification), and set thewhite_colour
,black_colour
andbackground_colour
to colours of your choice from this list. -
Run
chessplot.py
from the command line using either of the followingpython chessplot.py
python3 chessplot.py
The .png file containing the image should appear in the
chess-art/ImageFiles/
directory. -
Show your friends this cool new PGN art at the bar and the library!