Jump to content

File:Lichess funny.gif

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

Original file (800 × 800 pixels, file size: 661 KB, MIME type: image/gif, looped, 16 frames, 24 s)

Summary

Description
English: Black to move and funny.
Date 1/24/25
Source Own work
Author Kaotao
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 chess.pgn
import chess.svg

pgn = open('puzzle.pgn')
game = chess.pgn.read_game(pgn)
board = game.board()

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

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

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

i = 0
#try to find it!
while i < 10:
    s = chess.svg.board(board, orientation = chess.BLACK, size = 800)

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

    with open(f1, 'w') as f:
        f.write(s)
    os.system("convert %s %s" % (f1, f2))
    os.system("rm %s" % f1)
    i += 1

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

# pause animation at the end:
for j in range(3):
    svg(i)
    i += 1
# create animation with
# magick -delay 150 g_*.png -loop 0 g.gif

PGN

[Site "https://lichess.org/training"]
[FEN "1k3b1r/pppr1pp1/1q6/P3P1Qp/2p2P2/8/1PP3PP/R1B2R1K b - - 0 18"]

18... Qf2 19. Be3 Qxe3 *

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

Black to move.

Items portrayed in this file

depicts

24 January 25 CE

File history

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

Date/TimeThumbnailDimensionsUserComment
current02:00, 25 January 2025Thumbnail for version as of 02:00, 25 January 2025800 × 800 (661 KB)KaotaoUploaded own work with UploadWizard

The following page uses this file: