Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Icepool

A Python package for computing dice probabilities.

GitHub repository.

Features

  • Pure Python implementation.
  • Exact fractional probabilities using Python ints.
  • Dice support all standard operators (+, -, <, >, etc.) as well as an extensive library of functions (rerolling, exploding, etc.)
  • Can outperform sequence/multiset-based algorithms on many dice pool problems. In some cases it may be thousands or millions of times faster.

Installing

pip install icepool

The source is pure Python, so making a direct copy can work as well.

Contact

Feel free to open a discussion or issue on GitHub. You can also find me on Twitter or Reddit.

API documentation

pdoc on GitHub.

JupyterLite notebooks

See this JupyterLite distribution for a collection of interactive, editable examples. These include mechanics from published games, StackExchange, Reddit, and academic papers.

Web applications

Inline examples

Advanced Dungeons & Dragons 1st edition ability score methods

Source for these methods.

Method I:

All scores are recorded and arranged in the order the player desires. 4d6 are rolled, and the lowest die (or one of the lower) is discarded.

Method II:

All scores are recorded and arranged as in Method I. 3d6 are rolled 12 times and the highest 6 scores are retained.

Method III:

Scores rolled are according to each ability category, in order, STRENGTH, INTELLIGENCE, WISDOM, DEXTERITY, CONSTITUTION, CHARISMA. 3d6 are rolled 6 times for each ability, and the highest score in each category is retained for that category.

Method IV:

3d6 are rolled sufficient times to generate the 6 ability scores, in order, for 12 characters. The player then selects the single set of scores which he or she finds most desirable and these scores are noted on the character record sheet.

import icepool

"""
The @ operator means "roll the left die, then roll that many of the right die and sum".
Integers are treated as a die that always rolls that number.
Therefore:
* 3 @ icepool.d6 means 3d6.
* icepool.d6 @ 3 means roll a d6 and multiply the result by 3.
"""

method1 = 6 @ icepool.d6.keep_highest(num_dice=4, num_keep=3)
method2 = (3 @ icepool.d6).keep_highest(12, 6)
# num_keep defaults to 1.
method3 = 6 @ (3 @ icepool.d6).keep_highest(6)
method4 = (6 @ (3 @ icepool.d6)).keep_highest(12)

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(method1.outcomes(), method1.pmf(percent=True))
ax.plot(method2.outcomes(), method2.pmf(percent=True))
ax.plot(method3.outcomes(), method3.pmf(percent=True))
ax.plot(method4.outcomes(), method4.pmf(percent=True))
ax.set_title('AD&D 1e ability score methods')
ax.legend(['Method I', 'Method II', 'Method III', 'Method IV'])
ax.set_xlabel('Total of ability scores')
ax.set_xlim(50, 100)
ax.set_ylim(0)
ax.grid(True)
plt.show()

Metadata

Release files for icepool 0.10.3a0

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

Source distribution (sdist)

Source distribution for icepool 0.10.3a0
File Size Uploaded
icepool-0.10.3a0.tar.gz 31.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for icepool 0.10.3a0
File Interpreter ABI Platform
icepool-0.10.3a0-py3-none-any.whl Python 3 none any Details

Total release size: 65.8 kB

Release files / icepool-0.10.3a0.tar.gz

Download URL icepool-0.10.3a0.tar.gz
Size 31.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9aaaf1ff656bf0e52c00e726e5b8566958d1692f857020ed5eb667291f50344f
BLAKE2b-256 checksum
How to use checksums
7098e6533022eb0d205dc51adc217eba3a9f4c260edc7073545af4c88b9e6d09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / icepool-0.10.3a0-py3-none-any.whl

Download URL icepool-0.10.3a0-py3-none-any.whl
Size 34.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42212564fd30cbf600c27a64d9b9b68546817dcc0a2ff2fc34ccd5e2eb0e85d3
BLAKE2b-256 checksum
How to use checksums
4780e27c1661c695c94ecf2d6f90ed36aeebe6dd8f6009593d638f2f865adb3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.29.3

2 release files

0.29.2

2 release files

0.29.0

2 release files

0.28.1

2 release files

0.28.0

2 release files

0.27.1

2 release files

0.27.0

2 release files

0.25.6

2 release files

0.25.5

2 release files

0.25.4

2 release files

0.25.3

2 release files

0.25.2

2 release files

0.25.1

2 release files

0.25.0

2 release files

0.23.3

2 release files

0.23.2

2 release files

0.23.1

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.20.1

2 release files

0.19.1

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

This release

0.10.3a0 This release

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release 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