A fully-featured chess engine with graphical user interface and AI opponent
Project description
♟️ ChessyAI - Chess Engine
A fully-featured chess engine with graphical user interface and AI opponent built with Python and Pygame.
✨ Features
Complete Chess Rules
- ✅ All piece movements (Pawn, Rook, Knight, Bishop, Queen, King)
- ✅ Check detection
- ✅ Checkmate & Stalemate detection
- ✅ Castling (Kingside & Queenside)
- ✅ En Passant
- ✅ Pawn Promotion with piece selection dialog
🤖 AI Opponent
- ✅ Minimax algorithm with Alpha-Beta pruning
- ✅ Position evaluation with piece-square tables
- ✅ Configurable search depth
- ✅ Play as White against AI (Black)
User Interface
- ✅ Visual highlighting of valid moves
- ✅ Selected piece highlighting
- ✅ Last move highlighting
- ✅ Check warning (King highlighted in red)
- ✅ Game over dialog
- ✅ Move log panel
- ✅ Chess clock (10 min per player)
🔊 Sound Effects
- ✅ Move sounds
- ✅ Capture sounds
- ✅ Check warning
- ✅ Castling sound
- ✅ Game over sound
💾 Save & Export
- ✅ PGN export (save games)
Controls
| Key | Action |
|---|---|
Z |
Undo last move |
R |
Restart game |
S |
Save game as PGN |
F |
Force AI move (hint) |
| Mouse | Select and move pieces |
🚀 Installation
Using uv (Recommended)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/redbasecap/ChessyAI.git
cd ChessyAI
# Install dependencies
uv sync
# Generate sound effects (first time only)
uv run python generate_sounds.py
# Run the game
uv run python ChessMain.py
Using pip
# Clone the repository
git clone https://github.com/redbasecap/ChessyAI.git
cd ChessyAI
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install pygame
# Generate sound effects (first time only)
python generate_sounds.py
# Run the game
python ChessMain.py
🎮 How to Play
- Start the game with
uv run python ChessMain.py - Click on a piece to select it (valid moves will be highlighted in green)
- Click on a highlighted square to move the piece
- White (you) moves first, AI (Black) responds automatically
- Pawn promotion: When a pawn reaches the last rank, click on the piece you want
- The game ends when checkmate, stalemate, or time runs out
Player Configuration
Edit ChessMain.py to change who plays:
player_one = True # White: True = Human, False = AI
player_two = False # Black: True = Human, False = AI
📁 Project Structure
ChessyAI/
├── ChessEngine.py # Game logic and state management
├── ChessMain.py # GUI and user input handling
├── ChessAI.py # AI opponent (Minimax + Alpha-Beta)
├── generate_sounds.py # Sound effect generator
├── images/ # Chess piece sprites (PNG)
├── sounds/ # Sound effects (WAV)
├── games/ # Saved PGN files
├── pyproject.toml # Project configuration
└── README.md
🔧 Technical Details
Piece Notation
w = White, b = Black
K = King, Q = Queen, R = Rook, B = Bishop, N = Knight, p = Pawn
Example: "wK" = White King, "bp" = Black Pawn
Board Representation
The board is represented as an 8x8 2D array where "--" indicates an empty square.
AI Evaluation
| Piece | Value |
|---|---|
| King | ∞ |
| Queen | 900 |
| Rook | 500 |
| Bishop | 330 |
| Knight | 320 |
| Pawn | 100 |
The AI also uses position tables to prefer central control and piece development.
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
Possible Enhancements
- PGN import (load games)
- Move animations
- Online multiplayer
- Opening book
- Endgame tablebase
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chessyai-2.0.0.tar.gz.
File metadata
- Download URL: chessyai-2.0.0.tar.gz
- Upload date:
- Size: 119.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
967b859ec73ef0da457ba95f78ec04b2cc68c44b9e5b28f4fc76969f668dd490
|
|
| MD5 |
357f721585aeb67f371fc734c5ba2d3c
|
|
| BLAKE2b-256 |
2ea0caceed3e7b0f7c352adf44ed3b5b087c08a587ae704dbae37c04d17df559
|
Provenance
The following attestation bundles were made for chessyai-2.0.0.tar.gz:
Publisher:
release.yml on redbasecap/chessyAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chessyai-2.0.0.tar.gz -
Subject digest:
967b859ec73ef0da457ba95f78ec04b2cc68c44b9e5b28f4fc76969f668dd490 - Sigstore transparency entry: 775084773
- Sigstore integration time:
-
Permalink:
redbasecap/chessyAI@d4e15978c304aed10b5f678d8e2db41c71bc5411 -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/redbasecap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d4e15978c304aed10b5f678d8e2db41c71bc5411 -
Trigger Event:
push
-
Statement type:
File details
Details for the file chessyai-2.0.0-py3-none-any.whl.
File metadata
- Download URL: chessyai-2.0.0-py3-none-any.whl
- Upload date:
- Size: 132.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e750902886927024fbfd0cfb589e73f99d907032fd6684cf39b590537ca791bb
|
|
| MD5 |
5a6e1091853a97503a4dca5997faa370
|
|
| BLAKE2b-256 |
0c294dd5492c106743e3835e4945b40bdb62bf1a583b0182c5b4aad7095efd55
|
Provenance
The following attestation bundles were made for chessyai-2.0.0-py3-none-any.whl:
Publisher:
release.yml on redbasecap/chessyAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chessyai-2.0.0-py3-none-any.whl -
Subject digest:
e750902886927024fbfd0cfb589e73f99d907032fd6684cf39b590537ca791bb - Sigstore transparency entry: 775084779
- Sigstore integration time:
-
Permalink:
redbasecap/chessyAI@d4e15978c304aed10b5f678d8e2db41c71bc5411 -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/redbasecap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d4e15978c304aed10b5f678d8e2db41c71bc5411 -
Trigger Event:
push
-
Statement type: