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.2.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.2-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chessbuilder-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 92f32d767fbd83e38ca7df181dbfe0b677d9bf6554a359b64844dff995f55367
MD5 de3d01b7c645ca8b59db6357f62839f9
BLAKE2b-256 b43022f2d8c3d43bd0c4326a47ab3f3a85765883b2f983e9b1587b5ba0af30dc

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: chessbuilder-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3da0181658eeb262a985f172a64f3dcc25fee8aa12c5482df95c3025445ac28
MD5 3f5b049d6699436166ea81c408623cd1
BLAKE2b-256 c8fa239042877646c85df354289047a29dceb8a78d1754fc1db9bf115dc22d76

See more details on using hashes here.

Provenance

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