seededRandomfunction
A small seeded random number generator, so anything a game decides by chance — where the dead squares fall, which pieces come next — is fixed by the seed stored with the game and comes out the same on every replay.
Mulberry32: fast, tiny, and good enough for a board game. The seed is a 31-bit integer.
Import it
import { seededRandom } from "@johnmorrisdotca/narabe";
Definition
function seededRandom(seed: number): () => number
Parameters
| Name | Type | Description |
|---|---|---|
seed | number | The numeric seed for a reproducible random stream. |
Returns
() => number
A small seeded random number generator, so anything a game decides by chance — where the dead squares fall, which pieces come next — is fixed by the seed stored with the game and comes out the same on every replay. Mulberry32: fast, tiny, and good enough for a board game. The seed is a 31-bit integer.
Examples
import { seededRandom } from "@johnmorrisdotca/narabe";
console.log(seededRandom(42)());0.6011037519201636What it prints (run when this page was built)