Intro
A small script for running simulations with dice throws, including situations where you get multiple rerolls and can decide which dice to keep or reroll.
Usage
usage: dice.py [-h] [-n NUM] [-s SIDES] [-ss [SIDES [SIDES ...]]] [-r REROLL]
[--keep [STRATEGY [STRATEGY ...]]]
[--stats [REDUCE [REDUCE ...]]] [-N SIMULATIONS] [--counts]
Simulate various dice throw situations.
optional arguments:
-h, --help Show this help message and exit.
-n NUM Specify the number of dice to throw.
-s SIDES Specify the number of sides all dice have.
-ss [SIDES [SIDES ...]]
Specify the number of sides for each individual die.
-r REROLL Perform multiple rerolls (stats only count last roll).
--keep [STRATEGY [STRATEGY ...]]
Choose a keeping strategy when performing rerolls.
Options are: ['none', 'unique', 'duplicate', 'value'].
--stats [REDUCE [REDUCE ...]]
Performs multiple throws and outputs cumulative
results. Provide a parameter to choose an approach for
reducing a dice throw to a single value of interest.
Options are: ['count', 'sum', 'unique', 'values',
'order'].
-N SIMULATIONS Set the number of simulations to run for statistical
results.
--counts Print actual event counts instead of percentages in
the statistical results.
Examples
./dice.py [6] ./dice.py -n 2 [6, 5] ./dice.py -n 2 --stats sum Total sum of dice values in a throw: 2: 2.50 % 3: 4.50 % 4: 7.70 % 5: 11.20 % 6: 14.70 % 7: 19.20 % 8: 13.40 % 9: 9.80 % 10: 8.40 % 11: 5.60 % 12: 3.00 % ./dice.py -n 2 --stats count 1 6 Number of dice with the value [1, 6]: 0: 44.80 % 1: 43.60 % 2: 11.60 % ./dice.py -n 6 -r 3 [6, 5, 3, 2, 4, 3] [5, 2, 3, 4, 6, 4] [2, 5, 4, 2, 6, 6] ./dice.py -n 6 -r 3 --keep value 3 [6, 5, 3, 2, 4, 3] [3, 3, 5, 2, 3, 4] [3, 3, 3, 6, 4, 2] ./dice.py -n 6 -r 3 --keep value 3 --stats count 3 Number of dice with the value [3]: 0: 4.50 % 1: 16.30 % 2: 26.70 % 3: 31.20 % 4: 15.70 % 5: 5.10 % 6: 0.50 %
Terminology
Keep strategy: a strategy used to decide which dice to keep between rerolls
Reduction function: a function for reducing a dice throw result to a single value of interest
Metadata
Release files for dice-sim 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dice_sim-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for dice_sim-1.0.0-py2.py3-none-any.whl |
Release files / dice_sim-1.0.0-py2.py3-none-any.whl
| Download URL | dice_sim-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f3fc39f26cce37941de2a086ebb017c16a084d644c9b31d57a716ce5d60730de
|
|
BLAKE2b-256 checksum How to use checksums |
1b8707ce2598897bf2069a209d6bd67d6e94ea67b2ad91ef78f075a0ed03e768
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dice-sim 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.