An OpenAI Gym env for Slay the Spire.
All installation commands are expected to be run as root.
- Java JDK 8
- Docker
- A copy of Slay the Spire, particularly its
desktop-1.0.jar
file. - The JAR files for several mods:
- ModTheSpire
- BaseMod
- CommunicationMod
- SuperFastMode
This package has been tested with Python 3.9, but more recent Pythons may also work as long as you can build dependencies (there may not be prebuilt wheels).
IMPORTANT: These instructions assume you're a developer of this library, not that you're trying to add this library as a dependency for another project.
- Install the package along with its dependencies:
pip install -e .
# Alternatively, you can use poetry
poetry install
- Pull in required jar files. Directory structure should look like this:
gym-sts/
gym_sts/
...
lib/
desktop-1.0.jar
ModTheSpire.jar
mods/
BaseMod.jar
CommunicationMod.jar
SuperFastMode.jar
To build the Docker container:
from gym_sts.envs.base import SlayTheSpireGymEnv
SlayTheSpireGymEnv.build_image()
# On the host, make sure a loopback sound card has been created
modprobe snd-aloop # TODO can an index be assigned?
The Python script will start the container. You can communicate with the game using CommunicationMod commands via stdin.
python3 -m gym_sts.runner [lib_dir] [mod_dir] [out_dir] --headless
The Python script will start the game as a subprocess. This allows for easy observation of gameplay. You can communicate with the game using CommunicationMod commands via stdin.
python3 -m gym_sts.runner [lib_dir] [mod_dir] [out_dir]
- After cloning the project, use poetry to install dependencies in a virtual environment:
poetry install
# Enter the venv in a subshell
poetry shell
This project uses pre-commit to configure various linters/fixers. Make sure you've installed the pre-commit hook:
# Confirm pre-commit is installed
pre-commit -V
# Install the hook
pre-commit install
# Optionally run the linters manually
pre-commit run --all-files
Simply run pytest
from the project's root directory.