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

chancefunction

True with probability p, from 0 (never) to 1 (always): one draw.

Import it

import { chance } from "@johnmorrisdotca/tane";

Definition

function chance(random: Random, p: number): boolean

Parameters

NameTypeDescription
randomRandom

A random source returning values in [0, 1).

pnumber

The probability, from 0 to 1.

Returns

boolean

True with probability p, from 0 (never) to 1 (always): one draw.

Examples

import { chance, mulberry32 } from "@johnmorrisdotca/tane";

const random = mulberry32(42);
console.log(chance(random, 0.5));
false

What it prints (run when this page was built)

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