Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

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

NameTypeDescription
nodeMathNode

The arithmetic expression tree.

leavesreadonly 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)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.