A game where you play the tide, and the city comes back from a nine-character string
A game where you play the tide, and the whole city comes back from a nine-character string I built a small browser game called NULL TIDE. The pitch is strange enough that I usually have to explain it twice: you are not
A game where you play the tide, and the whole city comes back from a nine-character string
I built a small browser game called NULL TIDE. The pitch is strange enough that I usually have to explain it twice: you are not a character in it. You are the tide. Hold to pull the water back, let go to let it flood, and whatever the water leaves on the seabed gets picked up by the people in the city — a shoe, a brass bell, a wedding ring, an oil drum — and they build their whole culture around it.
Leave a sword twice and the district turns militarist. Leave a teddy bear and it turns tender. Ten tides in, a deep bell rings, the water leaves for good, and the city writes a four-line poem about you. That poem is the score. A run takes about twelve minutes.
I could spend this post describing the game, but the part I actually want to write about is the seed, because it solved a problem I did not expect to have.
The problem: I wanted people to share the ending, not just a screenshot
Every run ends with a card — the poem, a tiny pixel skyline, and the name the city gave you, like THE HALF-MERCIFUL or THE DROWNER. People share that kind of thing. But a screenshot of a poem is dead weight: you look at it, you do not get to play it.
I wanted the opposite. I wanted someone to see a card, type a string into the title screen, and land in the exact same city — same layout, same objects washing up on the same tides — then play it their own way and get a different verdict. That turns the share into a challenge instead of a receipt.
The only way to do that without a server is to make the whole thing a pure function of a seed.
How the seed works
A seed looks like TIDE-7F3K — a prefix and four characters from an alphabet with the ambiguous ones removed. It goes through two small functions:
function xmur3(str) {
let h = 1779033703 ^ str.length;
for (let i = 0; i < str.length; i++) {
h = Math.imul(h ^ str.charCodeAt(i), 3432918353);
h = h << 13 | h >>> 19;
}
return () => {
h = Math.imul(h ^ (h >>> 16), 2246822507);
h = Math.imul(h ^ (h >>> 13), 3266489909);
return (h ^= h >>> 16) >>> 0;
};
}
function mulberry32(a) {
return () => {
a |= 0; a = a + 0x6D2B79F5 | 0;
let t = Math.imul(a ^ a >>> 15, 1 | a);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
}
function makeRng(seed) { return mulberry32(xmur3(seed)()); }
xmur3 turns the string into a 32-bit integer. mulberry32 turns that integer into a stream of floats. That is the entire random engine — no library, no dependency, a few dozen lines.
When a run starts, newCity(seed) uses that stream for everything that defines the city: the layout, the deck of fourteen objects and the order it gets shuffled into, which objects surface on which tide. Same seed, same city, every time. I have one test that builds the city twice from a seed and compares the full state, and another that walks every authored ending to prove it is reachable. Those two tests are what let me change the simulation without quietly breaking replays.
Where I cheated, and why
Here is the part that took me longest to settle: not everything is seeded. Gulls, rain, and the ambient soundtrack use Math.random(). If I claim a seed reproduces a city, is that a lie?
I decided it is not, and the line I drew is this: the seed reproduces everything that determines the verdict. The layout and the object deck are seeded. The eulogy is computed from the traits your choices produce, with a seeded fallback when nothing wins. Gulls and rain are weather — they affect the mood, not the outcome. Two people playing TIDE-7F3K get the same city and the same rules and can compare their endings honestly. They just do not get the identical seagull at the identical second.
Being explicit about that line mattered more than I expected. The moment I stopped trying to make every pixel deterministic, the game got simpler and the replay guarantee got stronger.
The share card is the whole distribution plan
The card is drawn on a canvas and saved with toDataURL — no image server, no CDN, no upload. The seed is printed on it in plain text. So the artifact people want to post already contains the key to replaying the run. There is no account to sign up for and nothing to host.
The game itself is the same shape: one HTML file, one JS file, no build step, no network calls, no analytics. Open the page and it runs. That is partly a constraint I chose and partly stubbornness, but it means a link to the game is all anyone needs.
What I would change
Fourteen objects sounds like plenty until you watch someone play. On a first run they see maybe six. I spent too long adding objects early and not long enough making the ones that show up legible — the difference between a brass bell and an oil drum needs to be obvious in a glance. The last week went into that instead.
There is a free browser version and a five-dollar edition with the offline build and the soundtrack if you want to keep it. But the thing I am curious about is whether the seed-as-challenge idea works at all — whether anyone actually types the string in. I will know more after a few hundred people have played.
The game is at derbaroser-eng.github.io/null-tide and the source is on GitHub.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.