A multi‐mode chess AI project featuring:
- Easy mode: a Deep Q-Network (DQN) agent trained via OpenAI Gym & TensorFlow
- Medium/Hard modes: classical minimax search with alpha-beta pruning and a phase-aware static evaluation
- Interactive Pygame interface for human vs. AI play
demo.mp4
- Custom Gym environment (
ChessEnv.py) for RL training - Fast static evaluation tuned for opening development, middlegame tactics and endgame conversion
- Adaptive search depth based on material count (quicker in opening, deeper in endgame)
- Pygame GUI with piece sprites, menus & animations
- Clear project structure and comprehensive documentation
- Bots in three levels, with the hardest being at 1400 elo
-
Clone the repo
git clone https://github.com/AlirezaPrz/ChessAI.git
-
Create & activate a virtual environment
python3 -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
cd Chessbot
python src/train_model.pyThis will spin up the Gym environment, train the DQN agent, and save model weights under weights/.
cd Chessbot
python src/chess_main.py- On launch, choose Easy, Medium, or Hard mode.
- Use mouse clicks to move pieces.
- Z to undo, R to restart, Q to quit to menu.
Chess/
├── images/ # Piece sprites & menu graphics
│ ├── set1/
│ ├── set2/
│ └── start/
├── src/ # Source code
│ ├── weights/ # Trained DQN model files
│ ├── button.py # UI button class
│ ├── chess_engine.py # Core engine & move generation
│ ├── chess_env.py # Gym environment wrapper for RL
│ ├── minimax_bot.py # Minimax + evaluation + search
│ ├── train_model.py # RL training script for DQN agent
│ ├── chess_main.py # Pygame entry-point & menus
│ └── help.py # Misc utility functions
├── requirements.txt # `pip install` dependency list
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # MIT License
└── README.md # This file
Please see CONTRIBUTING.md for:
- Forking & cloning
- Branch naming conventions
- Coding style checks & pull request process
This project is licensed under the MIT License. See LICENSE for details.
Happy coding & enjoy your games!