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

faceStatsfunction

How often each face of one kind of die came up in a history, with a chi-square test of whether that looks fair. kind is a number of sides (or "F"), which counts the fair dice of that size and no loaded or custom one; or a group, which counts exactly that die. A numbered die, loaded or not, is tested against the fair die of its size; a custom die against its faces as written.

Import it

import { faceStats } from "@johnmorrisdotca/korokoro";

Definition

function faceStats(history: readonly Roll[], kind: Sides | DiceGroup): FaceStats

Parameters

NameTypeDescription
historyreadonly Roll[]

Completed rolls, newest first where the history API requires it.

kindDiceGroup | Sides

The die size or group whose face statistics are requested.

Returns

FaceStats

How often each face of one kind of die came up in a history, with a chi-square test of whether that looks fair. kind is a number of sides (or "F"), which counts the fair dice of that size and no loaded or custom one; or a group, which counts exactly that die. A numbered die, loaded or not, is tested against the fair die of its size; a custom die against its faces as written.

Examples

import { faceStats } from "@johnmorrisdotca/korokoro";
import { normalizeSpec, rollFrom } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
const sample = rollFrom(spec, [2, 5], "saved", 0, null)!;
console.log(faceStats([sample], 6)?.counts);
[ 0, 1, 0, 0, 1, 0 ]

What it prints (run when this page was built)

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