Skip to main content

Icepool

Python dice probability package.

GitHub repository.

PyPi page.

Try coding in your browser using Icecup, a simple frontend for scripting and graphing similar to AnyDice, SnakeEyes, and Troll. You can find a series of tutorials here.

Features

  • Pure Python implementation using only the Standard Library. Run it almost anywhere Python runs: program locally, share Jupyter notebooks, or build your own client-side web apps using Pyodide.
  • Dice support all standard operators (+, -, <, >, etc.) as well as an extensive library of functions (rerolling, exploding, etc.)
  • Efficient dice pool algorithm can solve keep-highest, finding sets and/or straights, RISK-like mechanics, and more in milliseconds, even for large pools.
  • Exact fractional probabilities using Python ints.
  • Some support for decks (aka sampling without replacement).

Installing

pip install icepool

The source is pure Python, so including a direct copy in your project can work as well.

Contact

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

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.

JupyterLite REPL.

As a backup, you can open the notebooks in Google Colab.

Tutorial notebooks

In particular, here is a series of tutorial notebooks.

StackExchange answers

Here is a full search of answers in which I mention Icepool.

Web applications

These are all client-side, powered by Pyodide. Perhaps you will find inspiration for your own application.

Paper on algorithm

Presented at Artificial Intelligence and Interactive Digital Entertainment (AIIDE) 2022.

In the official proceedings.

Preprint in this repository.

BibTeX:

@inproceedings{liu2022icepool,
    title={Icepool: Efficient Computation of Dice Pool Probabilities},
    author={Albert Julius Liu},
    booktitle={Eighteenth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment},
    volume={18},
    number={1},
    pages={258-265},
    year={2022},
    month={Oct.},
    eventdate={2022-10-24/2022-10-28},
    venue={Pomona, California},
    url={https://ojs.aaai.org/index.php/AIIDE/article/view/21971},
    doi={10.1609/aiide.v18i1.21971}
}

Versioning

Frankly, I haven't made backwards compatibility a top priority. If you need specific behavior, I recommend version pinning. Typing is especially unstable.

Similar projects

In roughly chronological order:

Troll by Torben Ægidius Mogensen

http://hjemmesider.diku.dk/~torbenm/Troll/

The oldest general-purpose dice probability calculator I know of. It has an accompanying peer-reviewed paper.

AnyDice by Jasper Flick

https://anydice.com/

Probably the most popular dice probability calculator in existence, and with good reason---its accessibility and shareability remains unparalleled. I still use it often for prototyping and as a second opinion.

SnakeEyes by Noé Falzon

https://snake-eyes.io/

SnakeEyes demonstrated the viability of browser-based, client-side dice calculation, as well as introducing me to Chart.js.

dice_roll.py by Ilmari Karonen

https://gist.github.com/vyznev/8f5e62c91ce4d8ca7841974c87271e2f

This demonstrated the trick of iterating "vertically" over the outcomes of dice in a dice pool, rather than "horizontally" through the dice---one of the insights into creating a much faster dice pool algorithm.

dyce by Matt Bogosian

https://github.com/posita/dyce

Another Python dice probability package. I've benefited greatly from exchanging our experiences.

Metadata

Release files for icepool 2.2.2

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 2.2.2
File Size Uploaded
icepool-2.2.2.tar.gz 115.5 kB Details

Built distribution (wheel)

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

Total release size: 256.9 kB

Release files / icepool-2.2.2.tar.gz

Download URL icepool-2.2.2.tar.gz
Size 115.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a93de43584cde02c3a7642b8cefeb50e60a4e6482aa5aabb28a8765bc7664ea
BLAKE2b-256 checksum
How to use checksums
44a80c717b8876f03c3ad4faddfe0c746cf30fd398c540e279265ee5b95a4d1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / icepool-2.2.2-py3-none-any.whl

Download URL icepool-2.2.2-py3-none-any.whl
Size 141.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b6e789b6c16b24ad6ea8c9c124c6a5e077b2a5420e61958041def02cb076304
BLAKE2b-256 checksum
How to use checksums
5879d7988f7798bb16e104d86f15ff6c4762dc258b5366a2cbc272edcf6a3fc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

2.2.2 This release

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

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