Jump to content

File:Scachs d'amor.gif

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (812 × 812 pixels, file size: 1.83 MB, MIME type: image/gif, looped, 44 frames, 1 min 6 s)

Summary

Description
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
Date
Source Own work based on code by Morn adapted by Amit Dash
Author Alexcalamaro
GIF development
InfoField
 
This GIF graphic was created with Python.
Source code
InfoField

Python code

Source code
#!/usr/bin/env python3

# Plot a PGN game using python-chess and ImageMagick

import os
import sys
import getopt
import chess.pgn
import chess.svg

def generate_png(board, i):
	lm = board.peek()
	a = [(lm.from_square, lm.to_square)]
	s = chess.svg.board(board, arrows = a)

	f1 = "g_%04u.svg" % i
	f2 = "g_%04u.png" % i

	with open(f1, 'w') as f:
		f.write(s)
	os.system("magick convert -density 200 %s %s" % (f1, f2))
	os.system("magick rm %s" % f1)

def get_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='])
	except getopt.GetoptError:
		print(help_message)
		sys.exit(2)

	for opt, arg in opts:
		if opt in ('-h', '--help'):
			print(help_message)
			sys.exit(2)
		elif opt in ("-p", "--pgn"):
			return arg
	
	single_arg = ''
	if args:
		single_arg = args[0]
	if single_arg and not single_arg.isspace():
		return single_arg

	print("No valid arguments could be found")
	print(help_message)
	sys.exit(2)

def main(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 = 1

	for m in game.mainline_moves():
		board.push(m)
		generate_png(board, i)
		i += 1

	# Duplicate last frame 3 times for pause animation at the end
	for j in range(3):
		generate_png(board, i)
		i += 1

	# Convert PGNs to GIF
	os.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:])

PGN

[Site "Valencia, Crown of Aragon"]
[Date "1475"]
[White "Francesc de Castellví"]
[Black "Narcís Vinyoles"]
[Result "1-0"]
[ECO "B01"]

1.e4 d5 2.exd5 Qxd5 3.Nc3 Qd8 4.Bc4 Nf6 5.Nf3 Bg4 6.h3 Bxf3 7.Qxf3 e6 8.Qxb7 Nbd7 9.Nb5 Rc8 10.Nxa7 Nb6 11.Nxc8 Nxc8 12.d4 Nd6 13.Bb5+ Nxb5 14.Qxb5+ Nd7 15.d5 exd5 16.Be3 Bd6 17.Rd1 Qf6 18.Rxd5 Qg6 19.Bf4 Bxf4 20.Qxd7+ Kf8 21.Qd8# 1-0

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
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.

Captions

Chess game "Scachs d'amor", 1475

Items portrayed in this file

depicts

7 November 2021

image/gif

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current14:51, 7 November 2021Thumbnail for version as of 14:51, 7 November 2021812 × 812 (1.83 MB)AlexcalamaroReduced resolution (812x812) to facilitate animation
13:16, 7 November 2021Thumbnail for version as of 13:16, 7 November 20211,625 × 1,625 (3.83 MB)AlexcalamaroUploaded own work with UploadWizard

The following page uses this file:

Global file usage