Dice probability package.
Project description
Icepool
Python dice probability package.
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
JupyterLite notebooks
See this JupyterLite distribution for a collection of interactive, editable examples. These include mechanics from published games, StackExchange, Reddit, and academic papers.
As a backup, you can open the notebooks in Google Colab.
Tutorial notebooks
In particular, here is a series of tutorial notebooks.
StackExchange answers
- Call-on traits in Burning Wheel: Success-counting dice pools with explosions and rerolls.
- Vampire the Masquerade V
- Roll multiple ability score arrays and pick the one with the highest total. What is the distribution of each ranked score?
- Year Zero Engine
- Neon City Overdrive
- Broken Compass / Household / Outgunned
- Probability that 0/4 players is dealt Blackjack
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.
- Icecup, a simple frontend for scripting and graphing.
- Alex Recarey's Face 2 Face Calculator for Infinity the Game -- including the ability to be installed on Android and iOS and run without an internet connection.
- Ability score rolling method calculator.
- Cortex Prime calculator.
- Legends of the Wulin calculator.
- Year Zero Engine calculator.
Paper on algorithm
Presented at Artificial Intelligence and Interactive Digital Entertainment (AIIDE) 2022.
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
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
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file icepool-2.2.1.tar.gz.
File metadata
- Download URL: icepool-2.2.1.tar.gz
- Upload date:
- Size: 114.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e4ca4584023ece1387986ed2e23ed51b85c9b46231be5819effa8a9a0441e0
|
|
| MD5 |
50e0475ef5f7e8dc47f23eb317cee8ae
|
|
| BLAKE2b-256 |
087bcbad01558cbc52abe3d82729301a1ee13f7f83a720d08ed5590311f29dfd
|
File details
Details for the file icepool-2.2.1-py3-none-any.whl.
File metadata
- Download URL: icepool-2.2.1-py3-none-any.whl
- Upload date:
- Size: 140.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41ea2ce0d84eaacb519871867466a2b095839078fa7c22b90d736efc4e426060
|
|
| MD5 |
79cd403cdc341ae7645519115fc96970
|
|
| BLAKE2b-256 |
ce74991b2be73a138734f6b64c5e60b8eed75ef0797f951571672cacaf061358
|