Reference · Cube engine and views
seededRandomfunction
A SEEDED RANDOM SOURCE: the same seed gives the same numbers, in the same
order, on every device and in every version from 1.1.0 on. Hand it to
randomScramble and two people a world apart turn the same scramble.
The seed is any text. It is hashed to 32 bits (xmur3) and the numbers come from mulberry32: small, quick and even enough for a scramble. It is not for secrets.
Import it
import { seededRandom } from "@johnmorrisdotca/kyuubu";
Definition
function seededRandom(seed: string): () => number
Parameters
| Name | Type | Description |
|---|---|---|
seed | string | Text that reproduces the same random sequence. |
Returns
() => number
A SEEDED RANDOM SOURCE: the same seed gives the same numbers, in the same order, on every device and in every version from 1.1.0 on. Hand it to randomScramble and two people a world apart turn the same scramble. The seed is any text. It is hashed to 32 bits (xmur3) and the numbers come from mulberry32: small, quick and even enough for a scramble. It is not for secrets.
Examples
import { seededRandom } from "@johnmorrisdotca/kyuubu";
console.log(seededRandom("docs")());0.3628387039061636What it prints (run when this page was built)