Skip to main content

Library for simulating dice, dice rolls, and stats on dice.

Project description

About

die is a dice library, for RPG and Board Game games, experiments, whatever.

Speed / efficiency are not priorities.

Installing

via uv:

uv add die

via pip:

pip install die

Using

import die

d6 = die.Standard(6)
d6.roll()          # -> single roll, e.g. 4
d6.rolls(3)        # -> list of three rolls, e.g. [2, 6, 1]
d6 + 3             # -> roll + 3

roll = die.Roll((die.Standard(6), die.Standard(6)))
roll.roll()        # -> sum of both dice

best = die.Roll((d6, d6), func=max)
best.roll()        # -> higher of two d6

attack = die.parse('2d6+3')   # dice notation; also NdF fudge dice
attack.roll()

import random
seeded = die.Standard(6, rng=random.Random(42))  # reproducible rolls

See examples/demo.py for a fuller walk through.

Testing

ruff check . pytest

pre-commit runs ruff check and ruff format automatically before each commit:

pre-commit install
pre-commit run --all-files

History

See CHANGELOG for release history and breaking changes.

Project details


Download files

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

Source Distribution

die-2.0.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

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

die-2.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file die-2.0.0.tar.gz.

File metadata

  • Download URL: die-2.0.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for die-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ea39c1eed0dce80ca37b2ea577c13cedf40c5155ef86810e2e2b77958352f4fe
MD5 bf4946b92d2fe8fdd42a3c895c90803c
BLAKE2b-256 5cb1a634e659f3ba6867becabfa95a3643b7b5df7142100cf62d14e3e4eca3f9

See more details on using hashes here.

File details

Details for the file die-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: die-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for die-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efecd0d799deb70c6070760c7c0063c6b64f6ad9f83837ce3cdf969997d24e20
MD5 9921d6ecd1973bb6fcdf851b0ce3f76d
BLAKE2b-256 1711d59ab217bf6c3a9411cd2174ee57f246b946cb63f14d9e8ee156bcf78efa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page