Reference · Rolls and exact odds
spreadMathfunction
The odds of a formula: the chance of each whole number it can come to, given the chance of each total of each kind of dice. Exact in its arithmetic, because the kinds share no dice and each is named once.
Import it
import { spreadMath } from "@johnmorrisdotca/korokoro";
Definition
function spreadMath(node: MathNode, leaves: readonly Map<number, number>[]): Map<number, number>
Parameters
| Name | Type | Description |
|---|---|---|
node | MathNode | The arithmetic expression tree. |
leaves | readonly Map<number, number>[] | One map of outcome weights per dice group. |
Returns
Map<number, number>
The odds of a formula: the chance of each whole number it can come to, given the chance of each total of each kind of dice. Exact in its arithmetic, because the kinds share no dice and each is named once.
Examples
import { spreadMath } from "@johnmorrisdotca/korokoro";
console.log([...spreadMath({ kind: "dice", group: 0 }, [new Map([[1, 0.5], [2, 0.5]])])]);[ [ 1, 0.5 ], [ 2, 0.5 ] ]What it prints (run when this page was built)