Various board games and reinforcement learning agent trained via Q-learning. The agent can be trained for various episodes and played against. The code is meant to be flexible enough so that the agent can learn to play any board game that implements the Game abstract base class.
This project was completed in order to learn the basics of implementing Q-learning with a simple look up table for Q-values. Inspiration was taken from Reinforcement Learning: An Introduction
- numpy
python main.py -game tictactoe
python -m unittest discover -v
- Tic Tac Toe
- Connect Four
- Chomp
Alternate state representation of full board vs. 3 column state. Significantly reduces memory with little cost to agent performance.
While implementing the game, I encountered some interesting problems. For Chomp, it is especially important to know which rectangles of chocolate were eaten at the same time.
For example, although
0 1 1
0 1 1
P * *
and
0 1 1
0 1 1
P * *
are the same, they could have been arrived at in different ways, not necessarily temporally but in terms of which blocks were eaten together.
0|1 1
0|1 1
- -
P * *
and
0|1 1
- - -
0|1 1
- -
P * *
Just add your game class to the game module and make sure it is a subclass of the Game abstract base class. Then just pass in your game to the rl agent.
MIT © Jae Hun Ro