Skip to main content

A chess game builder with customizable rules and mechanics

Project description

Chess Builder

A custom chess variant in Pygame featuring:

  • Gold Collection: Pawns can accumulate gold.
  • Gold Transfer: Gold may be transfered between friendly pieces with the same logic as captures.
  • Piece Purchases: Spend gold to buy and place new pieces near your king.
  • Promotion Choices: Pawns can promote with an interactive menu.
  • Optional Time Controls: A built-in chess clock for timed games.

Features

  1. Gold Accumulation

    • When it's your turn click a pawn you've already selected once to collect gold.
    • Captured pieces add their accumulated gold to the capturing piece.
    • To transfer gold click the transfering piece and then click the friendly piece you wish to recieve the gold. The recieving piece must be in a square that the transfering piece could move to.
  2. Purchases

    • Kings can open a purchase overlay by clicking on them again (when it's your turn).
    • Spend gold to place new pieces next to your king if it does not leave you in check.
    • Each piece has a cost (Pawn=1, Knight=3, Bishop=3, Rook=5, Queen=9).
  3. Promotion Menu

    • When a pawn reaches the last rank, a promotion menu appears so you can choose a new piece.
  4. Time Controls (Optional)

    • A chess clock can be activated, with multiple standard time options.
    • Each clock runs only during its respective turn.
  5. Draw/Win Conditions

    • Threefold repetition and the 50-move rule trigger draws.
    • Standard checkmate/stalemate detection for wins/losses.

Installation

Option 1: Install from PyPI (Recommended)

pip install chessbuilder

Option 2: Install from Source

  1. Install Python (3.7+ recommended)

  2. Clone the repository:

    git clone https://github.com/badgkat/ChessBuilder.git
    cd ChessBuilder
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Development Setup

If you want to contribute or modify the code:

  1. Clone and install dev dependencies:

    git clone https://github.com/YourUsername/ChessBuilder.git
    cd ChessBuilder
    pip install -r requirements-dev.txt
    
  2. Install in editable mode:

    pip install -e .
    
  3. Run tests:

    pytest
    

Running

Within the project directory, run:

python main.py

(or python3 main.py on some systems)

Usage

  • Start New Game
    Press New Game in the pause menu (hit Esc). You may be prompted to select a time control if you've enabled the chess clock.
  • Moving Pieces
    Click a piece to see valid moves/captures.
  • Collecting Gold
    If the currently moving side is not in check, and you have a pawn selected, click the same pawn again to collect gold.
  • Buying Pieces
    Select your king, then click the king again to open the purchase overlay if you have enough gold.
  • Promotion
    When a pawn reaches the last rank, a promotion menu appears so you can choose a new piece.
  • Pausing/Exiting
    Press Esc to toggle the pause menu or exit the game.

Controls

  • Esc: Toggles the pause menu or closes overlays.
  • C: Copies the move log to your clipboard.
  • Mouse Wheel (over the right panel): Scrolls the move log.

Chess Clock (Optional)

  • At game start, select a time format (e.g. "3|2") if time control is enabled.
  • Each player's clock runs only during their turn.
  • When you end your turn, any increment is added to the side that just moved.

Code Organization

  • board.py: Contains constants for the board (dimensions, colors), plus the Piece class, and movement logic.
  • clock.py (optional): Implements a chess clock with starting time, increment, and methods for updating.
  • game.py: Holds the primary Game class, controlling board state, gold mechanics, promotions, overlays, and drawing calls.
  • main.py: The main entry point with the game loop (main()).

To Do

  • General UI beautifying.
  • Adding Animations.
  • Add an AI.
  • Add non-local play.

Known Limitations

  • No castling. As the king must move to build a rook there is no situation where castling would be possible.
  • En Passsant logic only covers standard piece movement, not placed pawns.

Contributing

Pull requests and suggestions welcome! If you have ideas or new features, open an issue or submit a PR.

License

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


Enjoy building armies of gold-accumulating pieces and exploring this unique twist on classic chess!

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

chessbuilder-0.1.15.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chessbuilder-0.1.15-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file chessbuilder-0.1.15.tar.gz.

File metadata

  • Download URL: chessbuilder-0.1.15.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for chessbuilder-0.1.15.tar.gz
Algorithm Hash digest
SHA256 53809da2b2f439a03178044668988cb0d0db8b2791006ed5b2ec42b102e33213
MD5 c7fad474c728f7e2107d59b0bf605fd5
BLAKE2b-256 4c813275a3361661363edef3d0b7b99af30b7e0e1ffbc50b8728854c1cb2b1a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for chessbuilder-0.1.15.tar.gz:

Publisher: pypi-publish.yml on badgkat/ChessBuilder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chessbuilder-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: chessbuilder-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for chessbuilder-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 7b017547584bd2c1a7c82344d3374d79a33e5e51c1e0839e957ee20a508950d1
MD5 8ab8c9fd307363bca9f94a3d5d327af7
BLAKE2b-256 4545f0a2dfefc440ba558805a0caa0fb0fc5fd4611177f44680a0a03df524f6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for chessbuilder-0.1.15-py3-none-any.whl:

Publisher: pypi-publish.yml on badgkat/ChessBuilder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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