DEV Community

Atakan Kartli
Atakan Kartli

Posted on Edited on Fully Autonomous

A daily puzzle with no server: seeded RNG, tiling instead of solving, and pointer-event drag

I wanted a tiny daily puzzle for the browser, Wordle-sized, where every visitor gets the same board on the same day, but without a server, a database or a build step. Here is how it works. You can play the result here: Noodle Pop Daily.

The puzzle

A 5x4 case and five pieces made of balls (Kanoodle-style polyominoes). You drag pieces in, tap to rotate, flip to mirror. The game only checks one thing at the end: are all 20 holes filled? Any full board counts, so I never need to store "the" solution.

1. A seed from the date

const now = new Date();
const dayKey = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
let seed = 0;
for (const ch of 'noodlepop' + dayKey) seed = (seed * 31 + ch.charCodeAt(0)) >>> 0;
💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด

Local date on purpose: the board flips at the player's midnight, like a newspaper.

2. A tiny deterministic RNG (mulberry32)

const rnd = () => {
  seed = (seed + 0x6D2B79F5) >>> 0;
  let t = seed;
  t = Math.imul(t ^ (t >>> 15), t | 1);
  t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
  return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด

Math.random() would give every visitor a different board. mulberry32 is 6 lines, fast, and identical in every browser.

3. Generate the board by cutting it up, not by solving it

The trick that removes the solver entirely: start from a full board and cut it into pieces. If the pieces come from a tiling, a solution is guaranteed to exist.

  • Take the first empty cell (top-left scan).
  • Grow a piece from it by repeatedly adding a random empty neighbour, until it reaches a random size of 3 to 5.
  • After each piece, flood-fill the empty cells. If any empty region is smaller than 3, this cut can never finish, so throw it away and try again.
  • Five pieces covering 20 cells and you are done.

With a seeded RNG, the "random" retries are deterministic too, so everyone ends up with the same tiling. In practice it takes a handful of attempts, and there is a fixed fallback tiling in case it ever runs out of tries.

4. Scramble the pieces

Each piece is rotated 0-3 times and maybe mirrored (again with rnd()), then normalised so its top-left is (0,0):

const norm = cs => { const mx = Math.min(...cs.map(c => c[0])), my = Math.min(...cs.map(c => c[1])); return cs.map(([x, y]) => [x - mx, y - my]); };
const rot  = cs => norm(cs.map(([x, y]) => [-y, x]));
const flip = cs => norm(cs.map(([x, y]) => [-x, y]));
💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด

5. Drag and snap with plain pointer events

One pointerdown on the piece, pointermove/pointerup on window. On drop, round the piece's top-left to the nearest cell and check every ball is in bounds and on an empty hole. A tap without movement rotates the piece. touch-action: none on the pieces stops the page from scrolling while you drag on a phone.

6. Streak and share, still serverless

The streak is two values in localStorage (count and last solved day). The share button uses navigator.share on phones and falls back to the clipboard:

Noodle Pop Daily Dec 4: solved in 23 s (streak 3)
https://www.clovercase.app/noodle-pop/daily/
💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: clovercase dev/a daily puzzle with no server seeded rng tiling instead of solving and pointer event drag io - สรุปดราม่าล่าสุด

What I would change

With only five pieces some days have several solutions. That is fine for a one-minute daily, but a bigger "Sunday board" would make the week feel like it ramps up. If you have opinions on that, I'd love to hear them.

The browser daily is a small spin-off of my free iPhone puzzle game Noodle Pop (200 levels on 11x5 cases). Kanoodle-style, not affiliated with Educational Insights. The ball art is AI-generated and this code was written with an AI coding assistant.

Top comments (0)