Skip to main content

A package for computing dice probabilities

Project description

A library for computing dice probabilities.

Basic objectives

  • Dice are assumed to have integer faces and finite range.
  • Not Monte-Carlo-based, though this does provide a sample() function.
  • Computations are done using float64. I considered exact fractions but I didn't want to deal with the possibility of integer overflow. I might revisit this in the future.

Example

from hdroller import Die

# A standard d10.
die = Die.d10

# A d10, exploding on highest face at most twice, similar to Legend of the Five Rings.
die = Die.d10.explode(2)

# Roll ten L5R dice and keep the five highest.
die = Die.d10.explode(2).keep_highest(10, 5)

# Plot it.
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(die.outcomes(), die.pmf())
plt.show()

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

hdroller-0.0.1.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

hdroller-0.0.1-py3-none-any.whl (17.9 kB view hashes)

Uploaded Python 3

Supported by

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