Skip to main content

kirby-dice

Fair, seeded, replayable dice for the Kirby HERO System platform.

This package rolls dice and does nothing else. It has no dependencies and holds no game rules — what a roll means is the caller's business.

Attribution

The roller is based in part on the work of Bill Bame, shared informally and with thanks. No licence condition attaches to it; the credit is here because it is owed.

Why this is its own package

Players are, reasonably, funny about dice. A roller buried inside a combat engine can assert that it is fair. One that ships on its own can prove it.

The dice are fair, and the tests say how we know. tests/test_fairness.py runs chi-square uniformity over 60,000 rolls, checks independence across all 36 ordered pairs of consecutive rolls, and pins the mean within five sigma of 3.5. Every test is seeded and therefore deterministic — a fairness test that fails once a fortnight only teaches people to re-run CI. Two of the tests guard the guards: a loaded die must trip the uniformity assertion, and twenty unseeded rollers must not share a seed.

Every fight can be replayed. A roller always reports the seed it rolls from. The seed is required: pass the one you are replaying, or ask for a fresh one by name:

from kirby_dice import RandomRoller

roller = RandomRoller.fresh()
fight = [roller.roll_dice(3, 6) for _ in range(40)]

# Record roller.seed alongside the fight, and it replays die for die.
replay = RandomRoller(seed=roller.seed)
assert [replay.roll_dice(3, 6) for _ in range(40)] == fight

An unseeded random.Random() draws from OS entropy, so the seed never exists as a value and a fight cannot be reproduced once fought. RandomRoller.fresh() picks its seed with secrets.randbits(64) instead — unguessable, so being recordable does not make the next roll predictable.

Usage

from kirby_dice import RandomRoller, FakeRoller

RandomRoller(seed=42).roll_dice(3, 6)         # -> [1, 1, 6]
RandomRoller.fresh().roll_dice(2, sides=20)  # any number of sides

FakeRoller([[3, 4, 5]]).roll_dice(3, 6)       # -> [3, 4, 5], for tests

DiceRoller is a Protocol, so any object with a matching roll_dice will do — that is the seam consumers inject through.

There is no roll_half_die()

A HERO half die is an extra whole d6 that the caller converts, next to the rest of its damage rules. This package had such a method once. It had no callers, and its mapping disagreed with the live conversion in the combat engine — the same d6 gave different results depending on which you asked. Two homes for one rule is how they drift apart. Roll dice here; convert them there.

Licence

PolyForm Noncommercial License 1.0.0 — see LICENSE.

Metadata

Release files for kirby-dice 0.2.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 kirby-dice 0.2.0
File Size Uploaded Provenance Actions
kirby_dice-0.2.0.tar.gz 12.1 kB Without provenance Details for kirby_dice-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kirby-dice 0.2.0
File Interpreter ABI Platform Actions
kirby_dice-0.2.0-py3-none-any.whl Python 3 none any Details for kirby_dice-0.2.0-py3-none-any.whl

Total release size: 20.4 kB

Release files / kirby_dice-0.2.0.tar.gz

Download URL kirby_dice-0.2.0.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bae8c9500e44f98bc80d67b1562a3d258869fcd0e7826a37741833f97bc2aed0
BLAKE2b-256 checksum
How to use checksums
2d983bde91571012c472f70cb735445a226a346c8172f1a3a52e7e7979902775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / kirby_dice-0.2.0-py3-none-any.whl

Download URL kirby_dice-0.2.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d26edcf3e5ce2a588384f4ceb58d6774861b39848b7ebde49b29a386a2d83036
BLAKE2b-256 checksum
How to use checksums
181f5f57345d52383e9abb9ac5c8c2c2e54881820af764cf5a0838284c9dd823
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for kirby-dice 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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