r/reactnative • u/Ok-Percentage-1091 • 6d ago
News Real-time 1v1 sudoku with Expo + Firebase: what worked, and how I fixed empty lobbies with "ghost" replays
I shipped a sudoku game with live 1v1 duels to both stores, built solo with Expo. Some notes that might help anyone doing real-time features without a dedicated game server.
Architecture
- Expo / React Native with Expo Router, SQLite for local games, a small kv store for the active game.
- Moves go through a Cloud Function. Clients never write to the battle state; each move is a callable that checks it against the solution, counts mistakes and updates the shared state. Slower than peer-to-peer, but cheating is basically off the table.
- Live state in Realtime Database, clients subscribe to it. Fine latency for a game where a move every few seconds is normal.
- Rating: plain Elo with K=32, seasons of four months, and at season end everyone's rating moves halfway back to the start.
The empty lobby problem
With a small player base, quick match often finds nobody. I record every finished match as a list of timestamped events (positive = correct cell, negative = mistake). When nobody joins within a few seconds, the server picks a recorded match at a similar rating and difficulty, scales it to the new puzzle's blank count and replays it. The bot doesn't "solve" anything, the server just reveals events as time passes. It plays like a human because it was one, hesitation and mistakes included.
Difficulty grading
The generator rates each puzzle with a technique-based solver (naked/hidden singles, pointing pairs, box/line, naked triples, X-Wing, Swordfish, XY-Wing) instead of counting clues. The hardest technique needed decides the level.
Things I'd do differently
- Put anything that affects ranking behind a server call from day one. Retrofitting validation is painful.
- Keep native modules minimal: every one means a new store build instead of an OTA update.
Happy to go deeper on any part. If you want to see it running: Android · iOS


