English: Animation of the 1858 Opera Game between the American chess master Paul Morphy and two strong amateurs, the German noble Karl II, Duke of Brunswick and the French aristocrat Comte Isouard de Vauvenargues
#!/usr/bin/env python3# Plot a PGN game using python-chess and ImageMagickimportosimportchess.pgnimportchess.svgpgn=open('morphy_duke_karl_count_isouard_1858.pgn')game=chess.pgn.read_game(pgn)board=game.board()defsvg(i):lm=board.peek()a=[(lm.from_square,lm.to_square)]s=chess.svg.board(board,arrows=a,size=800)f1="g_%05u.svg"%if2="g_%05u.png"%iwithopen(f1,'w')asf:f.write(s)os.system("convert %s%s"%(f1,f2))os.system("rm %s"%f1)i=1formingame.mainline_moves():board.push(m)svg(i)i+=1# pause animation at the end:forjinrange(3):svg(i)i+=1# create animation with# convert -delay 150 g_*.png -loop 0 g.gif
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse
Captions
Add a one-line explanation of what this file represents