Inspiration
Daily puzzle games thrive on Reddit when every player in a community shares the exact same daily challenge, compares strategies in the comments without spoiling solutions, and competes for clean par efficiency. We wanted to build a tactile, fast-loading daily optical routing game that feels native to a Reddit feed — playable in seconds on both desktop and mobile without downloads, tutorials, or external accounts.
What it does
Prism Relay is a daily dual-wavelength optical routing puzzle built natively on Reddit Devvit Web and Redis:
- Deterministic UTC Daily Boards: Every calendar day (UTC) generates a shared 7x7 optical board via a seeded Mulberry32 PRNG and a constructive dual-wavelength convergence generator so every single daily puzzle is provably solvable and requires merging both Amber and Cyan laser wavelengths into White light.
- Exact Optimal Par Solver: An iterative-deepening minimal-optic solver computes the true optimal
Parfor each daily puzzle (always>= 3optics), rewarding players who find the cleanest beam-splitting and beam-merging geometry. - Tactile Board + Web Audio Feedback: Players place and rotate 45° Mirrors, Beam Splitters, and Color Mixers on a high-DPI HTML5 Canvas with real-time ray tracing (bounded 392-state loop-safe optical tracer), keyboard shortcuts, mobile touch targets, and synthesized Web Audio chimes.
- Native Reddit Community Loop: Powered by Express + Redis on Devvit Web:
- Daily leaderboard ranked by optics used vs. Par and solve time
- Community solve distribution histogram
- Daily play streak tracking per Redditor
- One-click spoiler-free emoji share card posted directly to the daily thread comments
- Automatic daily solver flair assignment
How we built it
- Frontend (
src/client/): TypeScript + Vite + high-DPI HTML5<canvas>renderer + Web Audio API chime synthesizer + accessible native<dialog>help/share modals, built with responsive layouts verified across both desktop (720pxDevvit iframe) and mobile (375px) viewports. - Shared Physics & Generator (
src/shared/): Pure TypeScript ray-tracing engine (engine.ts) with bounded state transitions preventing infinite mirror/splitter loops, paired with a constructive White-merge generator and exact Par solver (solver.ts). - Devvit Web Server (
src/server/index.ts): Express backend running inside Devvit Web v0.15.6 with Redis persistence for daily scores, streaks, histograms, server-side solution verification (anti-cheat validation against the deterministic daily board), andonAppInstall/onAppUpgradetriggers that automatically publish the interactive custom post.
Challenges we ran into
- Preventing infinite optical loops with beam splitters: Naive ray tracing can hang when splitters feed beams back into mirror cycles. We solved this by tracking visited
(row, col, dir, color)states across a bounded 392-state space so cyclic beams render cleanly and terminate deterministically. - Guaranteeing non-trivial daily White merges: Purely random placement occasionally produced trivial 1-optic boards or unmergeable beams. Switching to a constructive convergence builder verified by our exact iterative-deepening Par solver ensures 30/30 consecutive UTC daily seeds pass with
parOptics >= 3and a verified White-merge target. - Dual-mode playability: We built a standalone preview fallback so anyone inspecting the open-source repository can also play instantly on GitHub Pages without hitting 404 API errors, while the full Reddit experience runs natively inside Devvit Web with Redis.
Accomplishments that we're proud of
- Live playable Reddit custom post on
r/prism_relay_dev(withdevvit-dev-botinstalled for judge access) rendering smoothly inside the Reddit feed. - 100% deterministic verification suite (
vitest4/4 passing across 30 consecutive UTC daily boards, splitter loop termination, anti-cheat server validation, and spoiler-free share card generation) plus full headless desktop/mobile E2E verification with zero console errors.
What's next for Prism Relay
- Weekly community-created puzzle packs and custom board editor posts for subreddits
- Head-to-head daily challenge links and subreddit-wide seasonal par leaderboards
- Additional optical components (polarized gates and wavelength filters) for weekend hard-mode relays
Built With
- devvit
- express.js
- html5
- redis
- typescript
- vite
- web-audio