Reference · Streams, draws and seeds
drawSeedfunction
A seed from 1 to most, any of them as likely as another, skipping every
reserved block: one draw. The draw is spread over the seeds that are left
and then stepped over each block below it, so no seed is ever likelier than
another and no draw is wasted.
Import it
import { drawSeed } from "@johnmorrisdotca/tane";
Definition
function drawSeed(random: Random, options?: DrawSeedOptions): number
Parameters
| Name | Type | Description |
|---|---|---|
random | Random | A random source returning values in [0, 1). |
options (optional) | DrawSeedOptions | Seed-range options, including the upper bound and reserved blocks. |
Returns
number
A seed from 1 to most, any of them as likely as another, skipping every reserved block: one draw. The draw is spread over the seeds that are left and then stepped over each block below it, so no seed is ever likelier than another and no draw is wasted.
Examples
import { drawSeed, mulberry32 } from "@johnmorrisdotca/tane";
const random = mulberry32(42);
console.log(drawSeed(random, { most: 100, reserved: [{ from: 10, size: 5 }] }));63What it prints (run when this page was built)