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[];
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
min | number | The lowest total the dice can make. |
max | number | The highest total the dice can make. |
probabilities | number[] | 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 ]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。