This repository achieves three goals:
- Implements the game of Quoridor (rules).
- Uses self-play deep Q-Learning to train an AI agent to play the game.
- Let's users pause training and play against the AI at any point.
When the constant DISPLAY_GAME
is True, then the pygame window will open and the following commands will be available:
- d - Toggle redraws of the screen (drawing slows down learning)
- h - Jump into the game and start playing!
- f - Change the game speed
- r - Toggle full inference mode (100% prediction, no random moves for exploration)
main.py
- Runs a finite number of games. The AI learns by playing itself over and over.game.py
- Hasrun()
which is the game loop. Every turn is characterized by an agent evaluating the state, that agent making a move and the state being updated accordingly.display_game.py
Displays the game by mapping the state onto a graphical representation.actions.py
All the actions that an agent can take.state.py
The state of the game. This checks if actions are legal and converts between the global state and the agent's perspective of the state.model.py
This is the Q-learning neural network that makes action predictions and updates depending on the reward feedback.agents.py
This consists of an Agent class and two subclasses, each for the two agents playing. Each agent has a different view of the board so therefore need to convert the state to their perspective.
- Run
python -m venv venv
- Run
venv/Scripts/activate
(windows) - Run
pip install -r requirements.txt
- Run
python main.py
Note this project uses an older version of Tensorflow (1.14)