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.2.1.tar.gz (40.0 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.2.1-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chessbuilder-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ed6f090380609fc37daac6d57ef5361c40e4276f9629ba6e111069a4c2d5c97b
MD5 346555a1616784e76719c4d2a081ea2c
BLAKE2b-256 7d973cefef353a4d39006223b5082c6854920f05bc4fa604a872cb93c33a04fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for chessbuilder-0.2.1.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.2.1-py3-none-any.whl.

File metadata

  • Download URL: chessbuilder-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 37.0 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05e1ec0ed076d9f277a3a9151adf81d8bd23773163608e9ce38a34967d3e1524
MD5 2025eb359519374ea0b17136da9195c1
BLAKE2b-256 dc44cd9af92b3d4a23640198431874797b956fd54be76adadd4aee1412177c80

See more details on using hashes here.

Provenance

The following attestation bundles were made for chessbuilder-0.2.1-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