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

rollHeldfunction

Hold some dice of a roll and throw the rest again, as Yacht and Farkle do. held[i] is whether face i stays. The dice not held are thrown in order from the source, so from a seed the second roll replays like the first. The roll that comes back says which faces were held. Only plain dice can be held (canHold); anything else is a RangeError, as is a held that does not fit the roll.

Import it

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

Definition

function rollHeld(previous: Roll, held: readonly boolean[], source?: RandomSource, at?: number): Roll

Parameters

NameTypeDescription
previousRoll

The roll whose held dice must remain unchanged.

heldreadonly boolean[]

A mask marking dice whose faces stay fixed.

source (optional)RandomSource

A source of unsigned 32-bit integers; crypto by default where optional.

at (optional)number

The recorded time in epoch milliseconds.

Returns

Roll

Hold some dice of a roll and throw the rest again, as Yacht and Farkle do. held[i] is whether face i stays. The dice not held are thrown in order from the source, so from a seed the second roll replays like the first. The roll that comes back says which faces were held. Only plain dice can be held (canHold); anything else is a RangeError, as is a held that does not fit the roll.

Examples

import { rollHeld } from "@johnmorrisdotca/korokoro";
import { normalizeSpec, rollFrom, seededSource } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
const sample = rollFrom(spec, [2, 5], "saved", 0, null)!;
console.log(rollHeld(sample, [true, false], seededSource("next"), 1).faces);
[ 2, 2 ]

What it prints (run when this page was built)

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