This project demonstrates a simple reinforcement learning agent that learns to play chess through self‑play.
- Create a Python virtual environment.
- Install dependencies:
pip install -r requirements.txt
Run the training script to let the agent learn by self-play:
python -m chess_ai.train --episodes 1000 --checkpoint agent.pth
This will store a model checkpoint at agent.pth
.
After training, you can play against the agent either in the terminal or using the graphical interface.
python -m chess_ai.play_ui --model agent.pth
Moves are entered in UCI notation (e.g., e2e4
).
python -m chess_ai.play_pygame --model agent.pth
When a piece is selected, the square is highlighted and all legal target squares are marked. Click a highlighted square to move the piece. The AI will then make its move in response.
chess_ai/
– Package containing the environment, agent, and scriptsassets/svg/
– SVG icons for chess piecesplay_pygame.py
– interactive Pygame interfaceplay_ui.py
– terminal interfacetrain.py
– training entry point
requirements.txt
– Project dependenciesREADME.md
– Project overview and instructions