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

How-to

Keep features on separate streams

Give each feature its own sequence so adding one never changes another.

Derive by stable names

deriveSeed names independent work from a master seed. Adding another label’s stream does not consume or move the earlier ones. Labels are ordered text or integers, so use the same names and order on each host.

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

const deckSeed = deriveSeed(42, "deck");
const decoration = mulberry32(deriveSeed(42, "decoration"));
for (let draw = 0; draw < 20; draw += 1) decoration();
console.log(mulberry32(deckSeed)());
console.log(mulberry32(deriveSeed(42, "deck"))());
0.2015455993823707
0.2015455993823707

Fork by order

fork consumes one draw of its parent to seed a new source. It is useful when order is intentional; a named deriveSeed is better when features must remain stable as other work is added.

Keep draw counts deliberate

Sharing one mutable source across unrelated features couples their outputs. Use named sources for decks, terrain, decorations or test fixtures, and save each position you need to resume. Engine design explains the state and compatibility boundary.

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