Reference · Rolls and exact odds
luckOffunction
How lucky a total was, from 0 (the worst the dice can do) to 1 (the best): the share of rolls it beats, counting a tie as half. A 7 on 2d6 is 0.5.
Import it
import { luckOf } from "@johnmorrisdotca/korokoro";
Definition
function luckOf(spec: Odds, total: number): number
Parameters
| Name | Type | Description |
|---|---|---|
spec | Odds | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
total | number | The total to measure or compare. |
Returns
number
How lucky a total was, from 0 (the worst the dice can do) to 1 (the best): the share of rolls it beats, counting a tie as half. A 7 on 2d6 is 0.5.
Examples
import { luckOf } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
console.log(luckOf(spec, 7));0.5What it prints (run when this page was built)