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

MathNodetype

Arithmetic over the kinds of dice in a roll: (2d6+3)*2, 1d20-1d4, floor(4d6/2), max(1d6,1d8). A roll with a formula still throws its kinds of dice in order, exactly as it would without one; the formula is only how their totals are put together.

Everything is worked out in whole-number fractions, never in floating point, so floor(7/3*3) is 7 and not 6 or 8, in a roll and in its odds alike. A formula must come to a whole number: a division has to be rounded (floor, ceil or round) before it reaches the total.

Import it

import type { MathNode } from "@johnmorrisdotca/korokoro";

Definition

type MathNode = {
    kind: "dice";
    group: number;
} | {
    kind: "number";
    value: number;
} | {
    kind: "op";
    op: "+" | "-" | "*" | "/";
    left: MathNode;
    right: MathNode;
} | {
    kind: "call";
    name: MathFunction;
    args: MathNode[];
};

Examples

import type { MathNode } from "@johnmorrisdotca/korokoro";
const value: MathNode = { kind: "dice", group: 0 };
console.log(value.kind);
dice

What it prints (run when this page was built)

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