Skip to main content

A Manim plugin that allows you to generate scenes with chessboards with minimal setup.

Project description

Manim Chessboard

A Manim plugin that allows you to generate scenes with chessboards with minimal setup.

Installation

pip install manim-chessrender

Features

  • Initialize Chessboard: Easily create and display a fully initialized chessboard.
  • Move Pieces: Animate standard piece movements using UCI notation.
  • Special Moves: Handle special chess moves like castling and en passant.
  • Load FEN Strings: Load and display a board configuration from a FEN string.
  • Play PGN Files: Load and animate moves from PGN files.
  • Customization: Customize the appearance of the chessboard and pieces with different colors and image paths.

Usage

To render the examples, you need to run the script using Manim. Below are the examples included in this project.

MovePieceExample

This example initializes the chessboard and demonstrates moving a piece.

class MovePieceExample(MovingCameraScene):
    """
    Scene to demonstrate moving a piece on the chessboard.
    """
    def construct(self):
        """
        Constructs the scene by initializing the chessboard and moving a piece.
        """
        chessboard = ChessBoard()
        chessboard.initialize_board()
        self.add(chessboard.board)
        self.wait(1)
        self.play(chessboard.execute_move('e2e4'))
        self.wait(2)

PlayPGNExample

This example demonstrates playing moves from a PGN file on the chessboard.

class PlayPGNExample(MovingCameraScene):
    """
    Scene to demonstrate playing moves from a PGN file on the chessboard.
    """
    def construct(self):
        """
        Constructs the scene by loading a PGN file and animating the moves on the chessboard.
        """
        chessboard = ChessBoard()
        chessboard.initialize_board()
        self.add(chessboard.board)
        self.wait(1)
        
        games = chessboard.load_pgn("./example/example.pgn")
        game = games[0]
        for move in game:
            self.play(chessboard.execute_move(move.uci()))
            self.wait(0.5)

Running the Examples

To run any of the examples, execute the script using Manim. For instance, to run the InitializeChessBoard example:

manim -pql examples.py InitializeChessBoard

Replace InitializeChessBoard with the class name of the example you want to run.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manim_chessrender-0.1.1.tar.gz (168.3 kB view details)

Uploaded Source

Built Distribution

manim_chessrender-0.1.1-py3-none-any.whl (177.4 kB view details)

Uploaded Python 3

File details

Details for the file manim_chessrender-0.1.1.tar.gz.

File metadata

  • Download URL: manim_chessrender-0.1.1.tar.gz
  • Upload date:
  • Size: 168.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for manim_chessrender-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1915b4d0d02053320367cc624d5c637fc3e898916e5a556ca60d5f586cba3c92
MD5 f8b96edfd85ecde990a857b9a9dd134b
BLAKE2b-256 3950dca99522d22cdacd9cca38e345ba3a625765a5b4fbbd96b9c5e0bb6ff5cf

See more details on using hashes here.

File details

Details for the file manim_chessrender-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: manim_chessrender-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 177.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for manim_chessrender-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9182dbcf9e85bf9449f770b6d7dc0997a1cc217356fb0fea48ec0aafab7a4875
MD5 2b5736a724d04d070330e85b4bdafc4d
BLAKE2b-256 f800a57e6a37c048dab9e08896db71916d16aee8fb3eab8f8a99e73fdbf1cb7a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page