Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

How I Built a Zero-Asset Daily Block Puzzle Inside a Reddit Post (Mulberry32 +

I love 8×8 block-placement puzzles, but one thing always bothered me: every run is isolated RNG. You can't argue with friends about a tough turn because nobody received the same pieces. So I built BlockMerge — a seeded

I love 8×8 block-placement puzzles, but one thing always bothered me: every run is isolated RNG. You can't argue with friends about a tough turn because nobody received the same pieces.

So I built BlockMerge — a seeded daily 8×8 block puzzle that runs natively inside an interactive Reddit post via Devvit Web (React 19, TypeScript, Tailwind CSS v4, Express, and Redis).

Every UTC day, every player globally gets the exact same 3-piece waves, 3 official attempts to climb the Top 20 leaderboard, and a one-tap emoji score card to debate strategy in the comments.

👉 Play today's Daily Seed (#28) directly in your browser or Reddit app

Here are the 4 engineering decisions that mattered most.

1. Board-State-Independent Daily Waves (xmur3 + Mulberry32)

A naive daily PRNG pulls from a single shared random stream whenever the game asks for a block. That breaks the moment anything else consumes randomness (or if you ever want to inspect Wave N independently).

Instead, BlockMerge hashes the UTC date key (YYYY-MM-DD) via xmur3 into a canonical 32-bit seed, and isolates each 3-piece wave with its own Mulberry32 generator:

export function hashSeed(input: string): number {
  let h = 1779033703 ^ input.length;
  for (let i = 0; i < input.length; i += 1) {
    h = Math.imul(h ^ input.charCodeAt(i), 3432918353);
    h = (h << 13) | (h >>> 19);
  }
  h = Math.imul(h ^ (h >>> 16), 2246822507);
  h = Math.imul(h ^ (h >>> 13), 3266489909);
  return (h ^ (h >>> 16)) >>> 0;
}

export function mulberry32(initialSeed: number): () => number {
  let state = initialSeed >>> 0;
  return () => {
    state = (state + 0x6d2b79f5) >>> 0;
    let t = Math.imul(state ^ (state >>> 15), 1 | state);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}

export function getDailySeed(dateKey: string): number {
  return hashSeed(`blockmerge:daily:v1:${dateKey}`);
}

Because each wave is derived purely from (dailySeed, waveIndex):

  • Wave 14 delivers the exact same 3 blocks to every player on Earth, regardless of how they played Waves 1–13.
  • Players get 3 official attempts per day — Attempt 1 teaches you where the "wall" is, and Attempts 2 & 3 become a real optimization puzzle.

2. <1ms Server-Side Anti-Cheat via Deterministic Move Replay

Client-submitted scores on web games are trivial to spoof in DevTools. Because the core game engine is pure TypeScript shared between client and server, BlockMerge never trusts a client score.

Instead, the client submits a compact array of move tuples:

// [dockSlotIndex, boardRow, boardCol]
type MoveTuple = [number, number, number];

When POST /api/score hits the Devvit Express server:

  1. It loads the canonical seed for the UTC date (or the run's Endless seed).
  2. It replays every [slot, row, col] tuple through the exact same pure engine in under 1 millisecond.
  3. It rejects illegal placements, computes the authoritative score/wave/streak, and writes only the verified score to a 7-day TTL Redis ZSET (604800s), keeping memory flat forever.

3. Zero-Asset Game Feel (iOS WKWebView Hardened)

Inside an embedded webview, fast load times make or break conversion. BlockMerge ships zero PNG block textures and zero MP3/WAV files:

  • GPU Drag Layer: Dragging runs on a persistent translate3d layer with zero per-pixel React re-renders and a proportional thumb-lift offset so your finger never hides the placement preview. Avoiding backdrop-filter / drop-shadow on moving pieces eliminated iOS WKWebView smearing.
  • Pre-Drop Line-Clear Anticipation: Before you lift your finger, any row or column that would clear lights up immediately.
  • Procedural Web Audio Synth: Tactile pop, thock, combo riffs, and rising pentatonic clear chords are synthesized on the fly via the Web Audio API, with synchronous gesture unlock and iOS interrupted audio context recovery.

4. Designing for Native Community Loops

Building inside an interactive Reddit post changes how you think about game UX:

  • Feed Scroll Safety: The inline splash card sets touch-action: pan-y so swiping past the post on mobile never gets trapped.
  • 2-Step Interactive Onboarding: Brand-new players start on a 2-move practice board (single row clear -> double cross-clear + 2× streak) before jumping straight into today's Daily Challenge.
  • Playable Challenge Posts: After any run, players can drop an 8×8 emoji score card in the comments or spin up a brand-new playable Challenge Post seeded with their exact run so others can try to beat their score.

Try Today's Daily Seed

If you enjoy daily logic puzzles (or want to see how a zero-asset interactive web game feels inside Reddit), give today's waves a shot:

I'd love developer feedback on the mobile drag feel, the 3-placement Streak Grace balance, and the difficulty ramp around Waves 10–15!

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.