本文へ移動

Korokoroコロコロ

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

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

目次

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

Distribution型

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

Exact odds for a spec, worked out rather than simulated: every total the dice can make and how likely it is.

Plain dice are counted. Ten d1000 is a million million million million million outcomes, far past what a number holds exactly, so the counts are kept as BigInt, whole and exact however large, and only turned into a probability at the end. exactCounts hands those counts out. Rerolled and exploding dice, and several dice kept from a pool, are not equally likely outcomes to count, so they are worked out as probabilities instead and are right to the last few digits a number holds. Nothing here is sampled or rounded off, and nothing is left out: exploding dice stop at MAX_EXPLOSIONS, in the roll and in the odds alike, so the odds are those of the dice as they are really thrown.

インポート

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

定義

type Distribution = {
    min: number;
    max: number;
    probabilities: number[];
};

メンバー

名前型説明
minnumber

The lowest total the dice can make.

maxnumber

The highest total the dice can make.

probabilitiesnumber[]

probabilities[i] is the chance of a total of min + i. Sums to 1.

例

import type { Distribution } from "@johnmorrisdotca/korokoro";
import { DEFAULT_SPEC, distributionOf } from "@johnmorrisdotca/korokoro";
const value: Distribution = distributionOf(DEFAULT_SPEC);
console.log([value.min, value.max]);
[ 2, 12 ]

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

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

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