DEV Community

Cover image for I built a stone-merging game with a global daily leaderboard
丙赟信息
丙赟信息

Posted on

I built a stone-merging game with a global daily leaderboard

I built Pebble Merge, a physics puzzle game that runs in the browser: drop stones, merge same-colored ones, score points, and try not to stack past the top line.

The part I care about most is the global daily leaderboard. Every day all players get the same seeded board (a new seed rolls at UTC midnight), so after you finish a round you can see where you rank worldwide.

Link: https://pebblemerge.bysoft.site/

Mid-game: the board gets crowded fast

Three modes:

  • Classic - beat your own best
  • Daily - same seed as everyone else, global board
  • Zen - no game over, just merge

How the leaderboard handles cheating

The client never sends a score. It sends a merge log. The server replays that log through the real game logic (core.js, the exact file the browser runs) and recomputes the score, then checks:

  1. the daily seed matches today's UTC seed
  2. the recomputed score equals the claimed score
  3. stone mass is conserved across the whole log
  4. the score is under the theoretical upper bound
  5. per-IP hourly submission cap

Inflated scores get rejected, and cheating means reimplementing the physics, not editing a number in devtools.

Stack

  • vanilla JS + Matter.js for the physics
  • static assets on Cloudflare Workers
  • Node + Express + Postgres for the score service, on a Synology NAS behind a Cloudflare tunnel

A finished round: 3299 points after 268 merges

That last one is the only reason a global leaderboard costs me nothing to run: no server bill, and I own the data.

Feedback on the physics tuning and bug reports are very welcome - I would rather hear what feels wrong now than after I add more modes.

Top comments (0)