This repo contains a C++ implementation of the game mechanics of the card game
regicide,
with wrappers for Python and WASM, and reinforcement learning models trained
via PyTorch.
Try the WASM version of the game here: once loaded, the game (including neural-net bots) should run fully in the browser, without requiring any connection to a server.
Install this package via Python's pip tool on the command line:
# activate anaconda/uv/whatever for Python env
git clone https://github.com/ahgamut/regi-py
cd regi-py
python3 -m pip install -e .The package ships a C++ extension (regi_py.core) that must be compiled for your
interpreter. Build it in-place and run the test suite with:
# from a fresh virtualenv
python -m pip install --upgrade pip setuptools wheel
python -m pip install "pybind11>=3"
python -m pip install -e .[dev] --no-build-isolation # builds the extension + test deps
pytest -qRe-run pip install -e . --no-build-isolation after any change to the C++ sources
under src/regi_py/core/ to rebuild the extension before testing.
python -m pytest webdriver/tests # NOT bare `pytest webdriver/tests`Run the driver.py to see a basic command-line simulation of the game, where
each player randomly selects a valid move to play.
# install the package first
python driver.pyTo use custom strategies available in the package, specify them with
--add-bot:
python driver.py --help # view options for bots
python driver.py --add-bot damage --add-bot preserveTo play locally, run webdriver/driver.py to play a 2-player game on your local server:
# install the package first
cd webdriver
python driver.py \
-n 1 \ # one human player needs to connect
--add-bot damage # add the 'damage' bot
# go to http://localhost:8888 in your browserYou can also build the WASM version and run it locally. To use the neural nets locally, you'll need to train them by yourself.
Subclass the BaseStrategy class with your own implementations that select what
attack/defense moves to make.

