Author: Bernhard Pfann
Article: https://towardsdatascience.com/tackling-uno-card-game-with-reinforcement-learning
Status: Done
In this project I tried to analytically derive an optimal strategy, for the classic UNO card game. To do so, I structured my work as follows:
- Creating a game engine of the UNO card game in Python from scratch
- Obtaining game statistics from simulating a series of 100,000 games
- Implementing basic Reinforcement Learning techniques (Q-Learning & Monte Carlo) in order to discover an optimal game strategy
UNO card engine: In order to train a Reinforcement Learning (RL) agent how to play intelligently, a fully-fledged game environment needs to be in place, capturing all the mechanics and rules of the game. Class objects for Card
, Deck
, Player
, Turn
and Game
are defined.
Statistics from simulations: By running multiple simulations of the game, the following questions are being tackled:
- How many turns do games last?
- How big is the advantage of the player making the first turn?
- What are the most likely situations in the course of a game?
Application of Reinforcement Learning: In agent.py, I defined the algorithm for a Q-Learning or Monte-Carlo agent, both working with a discrete state-action matrix. In config.py
the preferred algorithm can be selected together with its main tuning parameters. Finally the results after training the RL-model are being analyzed in terms to cumulative win-rate and obtained Q-values.
assets/
collection of .csv files that are generated by execution ofrun.py
notebooks/
analysis of simulated gamessrc/
core package to simulate gamesconfig.py
configurable parametersrun.py
executation file
Clone repository via HTTPS:
$ git clone https://github.com/bernhard-pfann/uno-card-game-rl.git
Install requirements and execute main file:
$ pip install -r requirements.txt
$ python run.py