Re-interprets the outcomes of a Die using an arbitrary mapping function.
All outcomes which mapped to the same value are merged into a single outcome with combined probability.
mapping function
new die with re-interpreted outcomes
Re-interprets the outcomes of a Die using an arbitrary mapping function. Unlike Die.interpret, this function can map each outcome to a distribution of multiple possible new outcomes, represented by a Die. The probabilities of all outcomes in this new Die should add up to 1, the Die.reroll function takes care of the conditional probabilities.
All outcomes which mapped to the same value are merged into a single outcome with combined probability. Comparison between outcomes is performed using fast-deep-equal.
new die with re-interpreted outcomes
Static
dStatic
ndProduce an array of identical dice: 2d6, 5d8, etc. The numbers numDice
and numSides
can be any positive integers. Each side has an equal probability.
number of dice
number of sides each die has
Static
pairCombines two dice using an arbitrary rule for interpreting the result.
new combined die
opposed.ts example
Static
Private
pairInternal function used in Die.pair()
.
function which determines how the outcomes should be combined
outcomes of the first die
outcomes of the second die
new combined outcomes
Static
poolCombines a pool of dice into a single Die using an arbitrary aggregation rule.
initial value of the accumulator variable
array of dice to combine into a pool
pool all possible outcome combinations aggregated as a single Die
Static
singleGenerated using TypeDoc
A Die is a wrapper over an immutable Map, where keys correspond to possible outcomes of rolling the die, and values determine the probability of the respective outcome.
Conceptually, any combination of dice is aggregated into a new Die which contains all possible outcomes of the combination.