Real-Time Multiplayer Card Game with Smart Matchmaking by Vipin VaratharajanReal-Time Multiplayer Card Game with Smart Matchmaking by Vipin Varatharajan

Real-Time Multiplayer Card Game with Smart Matchmaking

Vipin Varatharajan

Vipin Varatharajan

Project Overview:

Creating a seamless, real-time multiplayer card game for mobile presents significant technical hurdles: minimizing player wait times in queues, managing state synchronization without lag, preventing matches from dying when players disconnect, and providing a frictionless onboarding experience. I set out to build a highly polished, Uno-style multiplayer game from scratch to solve these challenges natively.

The Solution:

I engineered a cross-platform mobile game using Unity and Firebase. The architecture features a highly responsive real-time database schema coupled with serverless Cloud Functions (TypeScript) to authorize moves and handle matchmaking securely. To guarantee a perfect user experience, I implemented smart AI "mimics" that step in to fill lobbies and replace disconnected players on the fly, ensuring games are never interrupted.
Game's Home Screen With Different Game Mode Options
Game's Home Screen With Different Game Mode Options

Key Features

Real-Time Multiplayer Engine: Fast, authoritative server logic built on Firebase Cloud Functions to validate card plays, handle draw/skip/reverse logic, and synchronize the game state across clients.
Dynamic Matchmaking & Queue System: A hybrid matchmaking system that pairs real players, but seamlessly injects "Mimic" AI bots if human players aren't found within an 8-second window.
Frictionless Auth & Data Migration: Players can immediately play as anonymous guests. When they choose to link their Google or Facebook accounts, their anonymous progress, tokens, and diamonds are seamlessly migrated to a permanent profile.
Dynamic Battery & Performance Optimization: Scene-aware framerate capping (60 FPS during gameplay for smooth animations, 30 FPS in menus/leaderboards to save mobile battery life).
In-Game Economy & Ads: Fully integrated token/diamond economy, locked token mechanics, and dynamic Google AdMob banner placements based on screen real estate and premium user status.
Game's Leaderboards Section
Game's Leaderboards Section

Key Challenges

Challenge 1: Handling Race Conditions and Stale Moves in Real-Time
The Issue: In fast-paced card games, a player might attempt to play a card exactly as their turn times out or right after another player drops a "Skip" card. If the client sends a stale move, the entire game state could desynchronize or crash.
The Solution: I implemented strict backend validation. The cloud function verifies the turn index against the current game state before processing. If a stale move is detected (e.g., the card is no longer in hand or the turn has advanced), the system intercepts the error, clears the pending move, and safely ignores it without breaking the game loop. Non-fatal errors are filtered client-side so the UX remains uninterrupted.
Challenge 2: Preventing "Zombie" Lobbies and Disconnects
The Issue: Mobile players frequently drop connection or close the app. If a player leaves, the game stalls, ruining the experience for the remaining humans. Furthermore, players queuing up could be stuck indefinitely if the player base is temporarily low.
The Solution: I engineered an smart timeout and AI-replacement system. If a player times out 3 times in a row, the server securely swaps their ID with an AI bot mid-game, seamlessly transferring their hand to the bot. Additionally, the matchmaking queue utilizes a timer; if a human isn't found in 8 seconds, the server spins up "Mimic bots" with randomized, human-like reaction delays (using Box-Muller truncated normal distribution) to provide a realistic playing experience.
Challenge 3: Seamless Account Linking without Data Loss
The Issue: Forcing users to create an account immediately kills conversion rates. However, allowing anonymous play makes it difficult to retain data when the user eventually wants to save their progress using Google or Facebook.
The Solution: I wrote a custom pipeline that allows players to start anonymously. When they authenticate via OAuth, the system links the credentials, reads the data from the temporary anonymous Firebase UID, writes it to the new permanent UID, and deletes the old node in one fluid, asynchronous transaction. This allows users to seamlessly transfer their progress using Google or Facebook sign-in after initially logging in as anonymous user.
Challenge 4: Balancing Visual Polish with Mobile Battery Life
The Issue: Running a Unity game at 60 FPS constantly drains mobile batteries quickly and causes thermal throttling, which leads to bad user experience.
The Solution: I implemented an active scene-listener that dynamically throttles the application's target frame rate depending on the screen. During gameplay, the screen rate is to 60 FPS for fluid card animations (to avoid animation choppiness). Once the game ends, the app throttles down to 30 FPS, significantly reducing GPU overhead and preserving battery life.

Private Game Rooms for Playing With Friends
Private Game Rooms for Playing With Friends

Results & Impact

Successfully Launched: Published a highly complex, real-time multiplayer application to the Google Play Store with zero critical server-side crash loops.
Robust Architecture: The serverless architecture scales automatically to zero when inactive and handles high-concurrency game loops with minimal latency (~1.2s AI delay tuning for optimal pacing).
Player Retention: By prioritizing immediate anonymous access and instant matchmaking (using AI bots), player onboarding friction was reduced significantly.
Like this project

Posted Jun 17, 2026

Built a multiplayer card-game prototype with turn logic, special-card rules, responsive UI, and polished gameplay presentation.