Español: Primera partida de ajedrez conservada, recogida en el poema "Scachs d'amor" escrito en valenciano por Francisco de Castellví y Vic, Bernardo Fenollar y Narciso de Vinyoles en 1475
English: First preserved chess game, collected in the poem "Scachs d'amor" written in Valencian by Francisco de Castellví y Vic, Bernardo Fenollar and Narciso de Vinyoles in 1475
Català: Primera partida d'escacs conservada, recollida al poema "Escacs d'amor" escrit en valencià per Francesc de Castellví i Vic, Bernard Fenollar i Narcís de Vinyoles el 1945
#!/usr/bin/env python3# Plot a PGN game using python-chess and ImageMagickimportosimportsysimportgetoptimportchess.pgnimportchess.svgdefgenerate_png(board,i):lm=board.peek()a=[(lm.from_square,lm.to_square)]s=chess.svg.board(board,arrows=a)f1="g_%04u.svg"%if2="g_%04u.png"%iwithopen(f1,'w')asf:f.write(s)os.system("magick convert -density 200 %s%s"%(f1,f2))os.system("magick rm %s"%f1)defget_path_from_args(arguments):help_message='-----\nUSAGE\n-----\nchess_analysis.py [-h] [--help] [-p <pgn-path>] [--pgn <pgn-path>]'try:opts,args=getopt.getopt(arguments,'hp:',['help','pgn='])exceptgetopt.GetoptError:print(help_message)sys.exit(2)foropt,arginopts:ifoptin('-h','--help'):print(help_message)sys.exit(2)elifoptin("-p","--pgn"):returnargsingle_arg=''ifargs:single_arg=args[0]ifsingle_argandnotsingle_arg.isspace():returnsingle_argprint("No valid arguments could be found")print(help_message)sys.exit(2)defmain(argv):pgn_path=get_path_from_args(argv)print("Generating GIF for PGN - "+pgn_path)pgn=open(pgn_path)game=chess.pgn.read_game(pgn)board=game.board()i=1formingame.mainline_moves():board.push(m)generate_png(board,i)i+=1# Duplicate last frame 3 times for pause animation at the endforjinrange(3):generate_png(board,i)i+=1# Convert PGNs to GIFos.system("magick convert -delay 150 g_*.png -loop 0 g.gif")os.system("magick rm -f g_*.png")print("GIF has been generated successfully")if__name__=="__main__":main(sys.argv[1:])
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