本文へ移動

Korokoroコロコロ

ダイスを組み合わせて振り、ダイス表記を読み取り、正確な確率を調べます。履歴の保存やシードを指定した再現もできます。

「コロコロ」は、小さなものが転がる様子を表す言葉です。 名前について(英語)

目次

リファレンス · ロールと正確な確率

MathNode型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 type { MathNode } from "@johnmorrisdotca/korokoro";

定義

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

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/korokoro 1.16.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。