A chess engine built from scratch in Python with a graphical interface (Pygame) and an AI opponent powered by the Minimax algorithm with alpha-beta pruning.
Personal project — built to explore game theory, tree search algorithms, and board evaluation heuristics.
- Full chess GUI with drag-and-drop piece movement
- Legal move validation using
python-chess - AI opponent playing as Black
- Minimax search with configurable depth
- Alpha-beta pruning for performance optimization
- Position evaluation based on piece values and positional tables
The AI evaluates every possible move using a recursive tree search:
- Minimax — explores the game tree by alternating between maximizing (White) and minimizing (Black) scores
- Alpha-beta pruning — cuts off branches that can't influence the final decision, reducing the number of positions evaluated
- Evaluation function — assigns a score to each board state based on material (piece values) and positional bonuses (center control, king safety)
| Component | Technology |
|---|---|
| Language | Python |
| GUI | Pygame |
| Chess logic | python-chess |
| Algorithm | Minimax + Alpha-Beta pruning |
git clone https://github.com/AmZzPYJS/Python-Chess-AI.git
cd Python-Chess-AI
pip install -r requirements.txt
python main.pyPython-Chess-AI/
├── main.py # Entry point — game loop and GUI rendering
├── requirements.txt # Dependencies
├── screen/ # Screenshots
├── LICENSE
└── README.md
- Implementing a tree search algorithm (Minimax) and understanding its time complexity
- How alpha-beta pruning drastically reduces the search space
- Designing a board evaluation function with piece-square tables
- Building an interactive GUI with Pygame's event loop
- Working with the
python-chesslibrary for move generation and validation
MIT