AlphaDOM is a project focused on building a Deep Reinforcement Learning AI to play Dominion! Dominion is a deck-building card game where players compete to accumulate the most victory points by purchasing cards from a shared supply and strategically building their personal decks to optimize their actions, buys, and overall strategy.
sample_agents
folder using play.py
.The repository is generally organized as follows:
src/
: Main source code for RL agents
babyDOM/
: Our first RL agent that uses PPO and self-play for one kingdomgame_engine/
: Core game engine for running a game of Dominioncards/
: Definitions and instances of all cards used in the game.action.py
: Defines a possible action a player can takeeffects.py
: Defines various effects that can be applied by cards (e.g. drawing cards)game.py
: Game state informationphase.py
: Represents phases in the gameplayer.py
: Player state and actions.sample_agents
: Sample torch models trained on different board setupsvectorization/
: Converts game engine states to vectors for RL agents to usemain.py
: Main script to run the training processplay.py
: Script to play test against sample agentstests/
: Contains unit tests for the game enginePlay against any of our sample agents by running the following from the root directory:
python3 src/play.py
Create a virtual environment:
python3 -m venv alphaDOM_env
Activate the virtual environment:
source alphaDOM_env/bin/activate
Install dependencies:
pip install -r requirements.txt
To run the main training process, use the following command from the root directory of the project:
python3 src/main.py [arguments]
Results will be saved to the src/output directory!
The script accepts the following command-line arguments:
Argument | Type | Default | Description |
---|---|---|---|
--num_games |
int | 1000000 | Number of games to train |
--batch_size |
int | 32 | Batch size (in games) for training |
--update_epochs |
int | 5 | Number of epochs for each update |
--hidden_size |
int | 256 | Hidden size of the neural network |
--run_id |
str | "default_run" | Unique identifier for this run |
--checkpoint_path |
str | None | Path to a checkpoint file to load model weights from |
To ensure the game engine is functioning correctly, we have included a suite of unit tests:
python3 -m unittest discover -s tests
Or if you want to run a specific test, you can do something like:
python3 -m unittest tests.test_game_engine.TestGameEngine.test_merchant_card