The Nim game is a mathematical strategy game in which two players take turns removing sticks from distinct heaps. The player who removes the last stick loses. As a game in which states are fully observable and with much reduced state and action spaces compared to chess, it is the perfect game to code a Q-Learning RL agent from scratch.
- Clone the repository:
git clone https://github.com/PierreCounathe/Reinforcement-Learning-for-Nim-Game
cd Reinforcement-Learning-for-Nim-Game
pip3 install -r requirements.txt
- Train the Agent and specify its name and number of
training_epochs
:
python3 main.py --train-ai ai_name 5000
- Play against another human or against a trained Agent:
python3 main.py --two-players
python3 main.py --against-ai ai_name 5000