Reference · Rolls and exact odds
Distributiontype
Exact odds for a spec, worked out rather than simulated: every total the dice can make and how likely it is.
Plain dice are counted. Ten d1000 is a million million million million
million outcomes, far past what a number holds exactly, so the counts are
kept as BigInt, whole and exact however large, and only turned into a
probability at the end. exactCounts hands those counts out. Rerolled and
exploding dice, and several dice kept from a pool, are not equally likely
outcomes to count, so they are worked out as probabilities instead and are
right to the last few digits a number holds. Nothing here is sampled or
rounded off, and nothing is left out: exploding dice stop at
MAX_EXPLOSIONS, in the roll and in the odds alike, so the odds are those
of the dice as they are really thrown.
Import it
import type { Distribution } from "@johnmorrisdotca/korokoro";
Definition
type Distribution = {
min: number;
max: number;
probabilities: number[];
};
Members
| Name | Type | Description |
|---|---|---|
min | number | The lowest total the dice can make. |
max | number | The highest total the dice can make. |
probabilities | number[] | probabilities[i] is the chance of a total of min + i. Sums to 1. |
Examples
import type { Distribution } from "@johnmorrisdotca/korokoro";
import { DEFAULT_SPEC, distributionOf } from "@johnmorrisdotca/korokoro";
const value: Distribution = distributionOf(DEFAULT_SPEC);
console.log([value.min, value.max]);[ 2, 12 ]What it prints (run when this page was built)