Skip to the content

Tane種

Reproduce numbers from a seed, shuffle or pick items, share a daily puzzle and resume a saved stream.

Tane means seed in Japanese. About the name

Contents

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

NameTypeDescription
randomRandom

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 }] }));
63

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tane 1.3.0.