Skip to main content

Pyminion

tests

pyminion-logo

Pyminion is a library for executing and analyzing games of Dominion. At its core, pyminion implements the rules and logic of Dominion and provides an API to interact with the game engine. In addition, it enables interactive games through the command line and simulation of games between bots.

Table of Contents

Installation

Pyminion requires at least Python 3.12 and can easily be installed through pypi

python3 -m pip install pyminion

Usage

Setting up a game

To play an interactive game through the command line against a bot, initialize a human and a bot and assign them as players. Alternatively, games can be created between multiple humans or multiple bots.

from pyminion.expansions import base, intrigue, seaside, alchemy
from pyminion.game import Game
from pyminion.bots.examples import BigMoney
from pyminion.human import Human

# Initialize human and bot
human = Human()
bot = BigMoney()

# Setup the game
game = Game(players=[human, bot], expansions=[base.base_set, intrigue.intrigue_set, seaside.seaside_set, alchemy.alchemy_set])

# Play game
game.play()

Creating Bots

Defining new bots is relatively straightforward. Inherit from the BotDecider class and implement play and buy strategies in the action_priority and buy_priority methods respectively.

For example, here is a simple big money + smithy bot:

from pyminion.bots.bot import Bot, BotDecider
from pyminion.expansions.base import gold, province, silver, smithy
from pyminion.player import Player
from pyminion.game import Game

class BigMoneySmithyDecider(BotDecider):
    """
    Big money + smithy

    """

    def action_priority(self, player: Player, game: Game):
        yield smithy

    def buy_priority(self, player: Player, game: Game):
        money = player.state.money
        if money >= 8:
            yield province
        if money >= 6:
            yield gold
        if money == 4:
            yield smithy
        if money >= 3:
            yield silver

class BigMoneySmithy(Bot):
    def __init__(
        self,
        player_id: str = "big_money_smithy",
    ):
        super().__init__(decider=BigMoneySmithyDecider(), player_id=player_id)

To see other bot implementations with more advanced decision trees, see /bots

Running Simulations

Simulating multiple games is good metric for determining bot performance. To create a simulation, pass a pyminion game instance into the Simulator class and set the number of iterations to be run.

from pyminion.bots.examples import BigMoney, BigMoneySmithy
from pyminion.expansions.base import base_set, smithy
from pyminion.game import Game
from pyminion.simulator import Simulator

bm = BigMoney()
bm_smithy = BigMoneySmithy()

game = Game(players=[bm, bm_smithy], expansions=[base_set], kingdom_cards=[smithy], log_stdout=False)
sim = Simulator(game, iterations=1000)
result = sim.run()
print(result)

with the following terminal output:

~$ python simulation.py
Simulation Result: ran 1000 games
big_money won 110, lost 676, tied 214
big_money_smithy won 676, lost 110, tied 214

Please see /examples to see demo scripts.

Support

Please open an issue for support.

Contributing

Install this library, test it out, and report any bugs. A welcome contribution would be to create new bots, especially an implementation that uses machine learning to determine optimal play.

If you would like to contribute, please create a branch, add commits, and open a pull request.

Development

Pyminion uses uv for development.

uv sync                 # create the environment and install dev tools
uv run pytest           # run the tests
uv run mypy pyminion    # type check

Releasing

Bump the version with uv version <new-version> and merge it to master, then publish a GitHub release tagged v<new-version>. The release workflow builds the package and uploads it to PyPI.

Metadata

Release files for pyminion 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyminion 0.6.0
File Size Uploaded Provenance Actions
pyminion-0.6.0.tar.gz 55.0 kB With provenance Details for pyminion-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyminion 0.6.0
File Interpreter ABI Platform Actions
pyminion-0.6.0-py3-none-any.whl Python 3 none any Details for pyminion-0.6.0-py3-none-any.whl

Total release size: 121.7 kB

Release files / pyminion-0.6.0.tar.gz

Download URL pyminion-0.6.0.tar.gz
Size 55.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b71b65e3141ccb7f37f678cb78c5115c51446f9d2aa434fb8245b4a83342c419
BLAKE2b-256 checksum
How to use checksums
a34bb957b86e5459268ae3cba85060a7cd757136c68d1da1f700759cfdca3dce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / pyminion-0.6.0-py3-none-any.whl

Download URL pyminion-0.6.0-py3-none-any.whl
Size 66.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e33d8ce80fd21fdfa24420ac1ff9c9bb9afea152e5fb14075be24f4381262790
BLAKE2b-256 checksum
How to use checksums
95f11d6cf9a0b730e64431834cf6bbc56bc88aa309dbe81d096b868067ca94dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for pyminion 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyminion-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page