How TETERI is built

Seeded Randomness: Why Both Players Get the Same Pieces

A small deterministic generator, one shared number, and two identical bags on different machines.

In a duel, both players receive exactly the same sequence of pieces. That is not synchronised over the network — it falls out of a shared seed.

The generator

The game uses mulberry32, a small deterministic pseudo-random generator: it holds a 32-bit state, mixes it with shifts and multiplies, and returns a number between zero and one.

The important property is that the same seed always produces the same sequence, on any machine, in any browser, forever.

How it is used

The seven-bag shuffle draws from that generator rather than from the platform's random function. So the bag order is entirely determined by the seed.

At the start of a match, one side picks a random seed and sends it to the other. Both create their generator from it, both shuffle identically, and both see the same pieces in the same order. No further synchronisation is needed for the rest of the match.

Why this matters for fairness

Without it, a duel has a luck component nobody can see. One player gets a clean sequence, the other gets three S pieces in a row, and the result is partly the randomiser's opinion.

With a shared seed, that argument disappears. Both players faced identical material, so the difference in outcome is entirely the difference in play.

The secondary benefit

Determinism is enormously useful for testing. A test can create a game with a fixed seed and assert on exact outcomes, because the sequence will be the same on every run and every machine.

What is not seeded

The hole columns in garbage rows. Those are decided by the attacking player and transmitted with the attack, so they do not need to be reproducible — and making them reproducible would let a player predict where the gaps in incoming garbage will be, which would be worse.

That is a small design decision with a real consequence, and it is the kind of thing worth thinking about when you introduce determinism anywhere.

PLAY TETERI ALL ARTICLES