This project implements a chess game where a Reinforcement Learning (RL) agent plays against a Large Language Model (LLM). The game is visualized using a Pygame-based graphical user interface.
- RL agent trained using Proximal Policy Optimization (PPO) from Stable Baselines3
- LLM agent based on a simplified version of DistilGPT2
- Interactive chess board with move highlighting
- Real-time display of game information, including captured pieces and move history
- Customizable random seed for reproducibility
- Python 3.7+
- PyTorch
- Stable Baselines3
- Pygame
- python-chess
- transformers (Hugging Face)
-
Clone the repository:
git clone https://github.com/jrzmnt/chess-rl-vs-llm.git cd chess-rl-vs-llm
-
Install the required packages:
pip install -r requirements.txt
Run the main script to start the game:
python src\main.py
- The RL agent is trained using PPO on the custom chess environment defined in
chess_environment/chess_env.py
. - The LLM agent in
llm_player/llm_agent.py
generates moves based on the current board state using a simplified version of DistilGPT2. - The game alternates between the two agents, with each move being visualized on the chess board using the Pygame GUI implemented in
chess_gui.py
. - The
main.py
script orchestrates the game flow, including initialization, turn management, and game termination conditions. - The game continues until checkmate, stalemate, or the maximum number of moves is reached.
- Adjust the RL training parameters in
rl_player/rl_agent.py
- Modify the LLM prompt or model in
llm_player/llm_agent.py
- Customize the GUI appearance in
chess_gui.py
Contributions are welcome! Please feel free to submit a Pull Request.
- Stable Baselines3 for the RL implementation
- Hugging Face Transformers for the LLM implementation
- python-chess for the chess logic
- Pygame for the graphical interface
If you use this project in your research or wish to refer to our related work on games and artificial intelligence, please use the following BibTeX entry:
@article{monteiro2018beating,
title={Beating bomberman with artificial intelligence},
author={Monteiro, Juarez and Granada, Roger Leitzke and Pinto, Rafael and Barros, Rodrigo Coelho},
journal={Anais do XV Encontro Nacional de Intelig{\^e}ncia Artificial e Computacional (ENIAC 2018), 2018, Brasil.},
year={2018}
}
Created by Juarez Monteiro
LinkedIn: @juarez-monteiro
GitHub: @jrzmnt
This project is licensed under the MIT License - see the LICENSE file for details.