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

DiceWarGametype

A game of Dice War: its table, seed and moves (what is kept), and what they make.

Import it

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

Definition

type DiceWarGame = {
    players: string[];
    computers: boolean[];
    dice: number;
    sides: number;
    goal: DiceWarGoal;
    to: number;
    seed: string;
    moves: DiceWarMove[];
    phase: "playing" | "over";
    scores: number[];
    round: number;
    wars: number;
    stake: number;
    rollers: number[];
    throws: DiceWarThrow[];
    ended: DiceWarGoal | null;
};

Members

NameTypeDescription
playersstring[]
computersboolean[]
dicenumber
sidesnumber
goalDiceWarGoal
tonumber
seedstring
movesDiceWarMove[]

Every move so far, in order.

phase"playing" | "over"
scoresnumber[]

Each seat's points.

roundnumber

The round being played, from 1; once over, the round it ended in.

warsnumber

How many wars the round has been through.

stakenumber

The points at stake in this round now: 1, and one more for each war.

rollersnumber[]

The seats that roll next: everybody, or in a war those who tied.

throwsDiceWarThrow[]

Every throw so far, oldest first.

endedDiceWarGoal | null

Why the game ended: a player reached the score ("points"), or the rounds ran out ("rounds"). Null while it goes on.

Examples

import type { DiceWarGame } from "@johnmorrisdotca/korokoro";
import { startDiceWar } from "@johnmorrisdotca/korokoro";
const value: DiceWarGame = startDiceWar({ players: ["One", "Two"], computers: [true, true], seed: "docs" })!;
console.log(value.phase);
playing

What it prints (run when this page was built)

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