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, including when you did not give it one:

from kirby_dice import RandomRoller

roller = RandomRoller()
fight = [roller.roll_dice(3) 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) 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 picks its own 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)          # -> [1, 1, 6]
RandomRoller().roll_dice(2, sides=20)       # any number of sides

FakeRoller([[3, 4, 5]]).roll_dice(3)        # -> [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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kirby_dice-0.1.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kirby_dice-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file kirby_dice-0.1.1.tar.gz.

File metadata

  • Download URL: kirby_dice-0.1.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kirby_dice-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ce66c8336aeae0fb2f3139e73c5d1e5021f12f0bf34c48ca74c93e0d3d9d76f3
MD5 ec03907454c2c5a234f524df3dc40360
BLAKE2b-256 26e07071473afe7e1a6f7a2322ee514b897a0320cf0c4fbdd18fcadbfaa95454

See more details on using hashes here.

File details

Details for the file kirby_dice-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kirby_dice-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kirby_dice-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86e7d8951f31120a7d8fa7cf85dc2e413949239bc0f59ff262d9060d917f3b75
MD5 01ee38e40cbd28d53aa4ce127df0a292
BLAKE2b-256 9713b38440b69e2a30d52a20cd143395b13354d52d82ff5ad2a121584cea94dc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

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