Reference · Rolls and exact odds
presetOddsfunction
The exact odds of each outcome of a game's first roll: a natural in craps,
each hand in chinchirorin, each result of a Risk battle. Every way the dice
can fall is counted, in whole numbers. spec is the preset's own dice
unless others are given (a larger pool, fewer battle dice).
Null where there is nothing to count: a reading that is only the total,
whose odds distributionOf gives; a reading that depends on the order of
the dice; or dice that are rerolled or explode.
Import it
import { presetOdds } from "@johnmorrisdotca/korokoro";
Definition
function presetOdds(preset: Preset, spec?: RollSpec, language?: "en" | "ja"): OutcomeOdds[] | null
Parameters
| Name | Type | Description |
|---|---|---|
preset | Preset | The game preset whose dice and reading are used. |
spec (optional) | RollSpec | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
language (optional) | "en" | "ja" | English or Japanese for the reading text. |
Returns
OutcomeOdds[] | null
The exact odds of each outcome of a game's first roll: a natural in craps, each hand in chinchirorin, each result of a Risk battle. Every way the dice can fall is counted, in whole numbers. spec is the preset's own dice unless others are given (a larger pool, fewer battle dice). null where there is nothing to count: a reading that is only the total, whose odds distributionOf gives; a reading that depends on the order of the dice; or dice that are rerolled or explode.
Examples
import { presetOdds } from "@johnmorrisdotca/korokoro";
import { getPreset } from "@johnmorrisdotca/korokoro";
const preset = getPreset("cho-han")!;
console.log(presetOdds(preset)?.map((outcome) => outcome.text));[ 'Chō (even)', 'Han (odd)' ]What it prints (run when this page was built)