AI-Powered Cricket Management Simulation Game App by Vipin VaratharajanAI-Powered Cricket Management Simulation Game App by Vipin Varatharajan

AI-Powered Cricket Management Simulation Game App

Vipin Varatharajan

Vipin Varatharajan

Project Overview:

Creating a realistic sports management simulator presents unique technical challenges: managing strict, probabilistic math for match outcomes, handling highly concurrent multiplayer auction economies, and keeping textual commentary fresh and engaging across thousands of simulated matches. I engineered the backend for this cricket club manager, a comprehensive NestJS and Supabase-based application that seamlessly blends a highly complex sports simulation engine with the generative capabilities of Google's Gemini AI to deliver a hyper-realistic, endlessly varied gaming experience.

The Solution:

I built a robust backend architecture using NestJS and Supabase PostgreSQL. The system integrates advanced AI specifically designed to hydrate the game's strict, mathematical simulation events with natural language. To ensure the game felt alive, I engineered an AI-driven commentary template generation pipeline, where the LLM contextualizes the exact state of the match (e.g., pitch conditions, bowler type, batter aggression, and shot control) into dynamic prose. Additionally, I built an automated, globally synchronized virtual economy engine that manages daily player generation, squad contracts, and live bidding wars, utilizing secure database transactions to handle high-frequency auction concurrency.

Key Features

Deterministic Match Engine: A complex state-machine that evaluates bowler styles, pitch deterioration, batter stamina, running aggression, and real-time fielding presets to mathematically calculate the outcome of every single delivery across T10, T20, and ODI cricket match formats.
AI-Generated Ball-by-Ball Commentary: A scheduled serverless pipeline powered by Gemini AI that dynamically generates contextual commentary templates based on highly specific ball outcomes (e.g., a mistimed pull shot off a fast bowler on a green pitch), completely eliminating repetitive game text.
Live Multiplayer Player Auctions: A fully automated transfer market featuring dynamic player value algorithms, anti-snipe bid extensions, and scheduled server-side cron jobs that backfill global player supply daily.
Simulated Decision Review System (DRS): A mathematically rigorous recreation of real-world cricket technology (Hawk-Eye and Ultra-Edge). It calculates ball pitching zones, impact alignment, and exact wicket-hitting probabilities to allow managers to challenge umpire decisions.

Key Challenges

Challenge 1: Preventing Repetitive Game Commentary with AI

The Issue: Traditional sports games rely on a static, hardcoded database of commentary lines. After a few hours of gameplay, users hear the exact same phrases repeated endlessly, which destroys immersion, especially in a simulator where thousands of balls are bowled per day.
The Solution: I implemented an AI-driven content generation pipeline. Instead of writing thousands of lines of dialogue manually, the backend continually queries Gemini AI with extremely specific simulation constraints (e.g., "Write a commentary line for a Right Arm Fast bowler inducing a thick outside edge that drops short of first slip").
The AI's responses are sanitized, parsed for dynamic variables (like [batter], [bowler], and [shot]), and injected into the database as reusable templates. This ensures the game has an infinite, zero-maintenance pipeline of fresh, context-aware commentary.

Challenge 2: Securing the Multiplayer Auction Economy Against Race Conditions

The Issue: Handling virtual currency bids on live player auctions requires bulletproof transaction logic. If multiple users bid on a highly sought-after player in the final seconds of an auction, race conditions could lead to conflicting database states, negative balances, or lost virtual currency.
The Solution: I engineered a highly secure bidding pipeline using atomic transactions. When a user submits a bid, the backend first validates their virtual currency balance. It then executes a strict update sequence that locks the auction row, verifies the new bid is higher than the current_bid plus the BID_INCREMENT, deducts the currency from the new bidder, and refunds the previous highest_bidder_id simultaneously.
I also implemented an "anti-snipe" mechanism: if a bid is placed in the final 10 seconds, the auction's ending timestamp is automatically extended, ensuring fair competition and maximizing in-game currency sinks.
Live Player Auctions Screen
Live Player Auctions Screen

Challenge 3: Building a Realistic, Deterministic Match Engine

The Issue: Cricket is incredibly complex. Simulating a match requires tracking the physical stamina of fast bowlers vs. spinners, incorporating superiority of one team's ratings over the opponent, the psychological mood of the squad, the exact placement of 11 fielders on a coordinate grid, and the deterioration of the pitch over 300 deliveries.
The Solution: I engineered a deeply layered algorithm that calculates a base probability matrix for every ball. The system modifies these probabilities in real-time based on live manager inputs (e.g., changing batter aggression or moving a fielder to "deep third man").
For example, if a manager sets batter aggression to "very aggressive" against a spinner on a "dry pitch," the engine mathematically increases the weight of hitting a boundary, but severely inflates the multiplier for a wicket via a mistimed shot or stumping. This gives managers true, tactical agency over the simulation.

Results & Impact

Infinite Content Pipeline: The automated Gemini AI commentary system saved hundreds of hours of manual writing while providing an endlessly varied, dynamic narrative experience for players.
Enterprise-Grade Simulation: By chaining deep mathematical probability models with live user inputs, the app provides a highly accurate, tactical cricket management experience that rivals desktop simulators.
Bulletproof Economy: The atomic transaction architecture for player auctions resulted in zero duplicated bids or lost virtual currency, ensuring a trustworthy and highly competitive multiplayer transfer market.
Zero-Maintenance Automation: Squad repairs, contract expires, and daily match generations are entirely automated via backend schedulers, allowing the game to run autonomously.

App Screenshots

Cricket Stadium Controls Screen - Phone View
Cricket Stadium Controls Screen - Phone View
50 Over Championship League Table
50 Over Championship League Table
Players Squad Screen
Players Squad Screen
Hall of Fame - Phone View
Hall of Fame - Phone View
Like this project

Posted Jul 29, 2026

My personal project - engineered the entire cricket (sport) management game end-to-end. Built a realistic, probability-driven match simulation engine.