DEV Community

Prathamesh Chaumwal
Prathamesh Chaumwal

Posted on

Building MatchMind: An AI-Powered IPL Tactical War Room Using Multi-Agent Gemini Debates

Building MatchMind: An AI-Powered IPL Tactical War Room Using Multi-Agent Collaborative Debates with Gemini & OpenRouter

Featured at GDG Cloud Pune

Have you ever watched a high-stakes IPL match and yelled at your TV screen, "Why did he bowl spin in the 19th over?!" or "They need to attack Bumrah now, not later!"?

Cricket isn't just a game of physical skillβ€”it’s a dynamic game of high-pressure decisions. An elite captain absorbs pitch reports, analyzes dew levels, calculates player matchups, and runs critical alternate scenarios in a split second before making a game-changing tactical call.

In the spirit of showcasing cutting-edge AI integrations for the GDG Cloud Pune community, we built MatchMindβ€”an interactive, real-time IPL Tactical War Room. Instead of a generic stats chatbot, MatchMind models how elite captains think, debate, and adapt under immense pressure using a collaborative multi-agent debate chain powered by Gemini (via OpenRouter) and a React/Express stack.

Here is a look at the architecture, the custom prompt engineering behind the agents, and an end-to-end match scenario run.


πŸ—οΈ MatchMind Architecture

MatchMind is structured as a three-panel broadcast-style dashboard. The architecture is engineered around a stateful iterative orchestration system, separating real-time raw data ingestion from AI-based strategic debates.

                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚   Cricbuzz / Weather   β”‚
                  β”‚       API Fetch        β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ Live JSON
                              β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚    Express Backend     β”‚
                  β”‚      (Node.js)         β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β–Ό                                   β–Ό
   Iterative Agent Chain               Express Server Router
  (OpenRouter API Client)             (Port 3002 REST Endpoints)
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ 1. Match Analyst      β”‚            β”‚ GET /api/match-state  β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€            β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 2. Tactical Strategistβ”‚            β”‚ POST /api/debate      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€            β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 3. Devil's Advocate   β”‚            β”‚ POST /api/user-input  β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  β”‚ 4. Captain Decision   β”‚                        β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚ Proxied /api
                                                   β–Ό
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚ React / Vite Frontend β”‚
                                       β”‚      (Port 5173)      β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

πŸ–ΌοΈ Architecture Diagram Image Prompt

If you want to generate a sleek visual of this architecture for your blog, use this Midjourney/DALL-E prompt:
"A highly professional, modern, dark-themed software architecture diagram for a sports tech platform named 'MatchMind'. Dark blue background (#0B1020). Diagram shows three main columns connected with glowing neon-cyan arrows. Column 1 (Left): 'Data Ingestion' (Cricbuzz & Weather API). Column 2 (Middle): 'Express Orchestrator' running a multi-agent debate (Match Analyst, Tactical Strategist, Devil's Advocate, Captain Decision) via OpenRouter API. Column 3 (Right): 'Vite + React Dashboard' showing live UI panels. Sleek, broadcast-style, clean typography, minimalist icons, ultra-premium sports broadcast aesthetic."


πŸ€– The 4 Collaborative Agents & Custom Prompts

To model a realistic war room, a single generic prompt pretending to be multiple roles wasn't enough. MatchMind uses four independent system instructions executing in a sequential stateful turn-taking manner. Every 4 seconds, the orchestrator triggers the next agent in the queue, feeding them the cumulative context of the debate.

Here are the custom prompt structures we wrote for each agent:

1. πŸ” The Match Analyst Agent

  • Role: A pure data-driven professional analyst.
  • Objective: Ingest raw numbers (overs, runs, dew, pitch) and evaluate the immediate matchups.
  • Prompt:
  You are the Match Analyst Agent for a live IPL T20 match.
  Analyze the following live match state:
  Score: ${matchState.score}, Overs: ${matchState.overs}, RRR: ${matchState.reqRate}
  Batters: ${matchState.batter1}, ${matchState.batter2}
  Bowler: ${matchState.bowler}
  Pitch: ${matchState.pitch}, Dew: ${matchState.dew}

  Provide a concise, data-driven analysis of the tactical matchups and conditions in 2-3 sentences.
  Return ONLY valid JSON (no markdown fences): { "title": "Match Analyst Context", "content": "..." }
Enter fullscreen mode Exit fullscreen mode

2. ⚑ The Tactical Strategist Agent

  • Role: Propose bold game-changing moves by adapting to dynamic captaincy modes (Dhoni, Kohli, Rohit) based on pressure.
  • Prompt:
  You are the Tactical Strategist Agent for a live IPL T20 match.
  Based on the Analyst's context: "${matchState.debate[0]?.content}"
  Propose a bold tactical move (bowling change, batting attack, field setup). Choose a captaincy mode (Dhoni, Kohli, or Rohit).
  Return ONLY valid JSON: { "title": "Strategist (Mode Name)", "content": "..." }
Enter fullscreen mode Exit fullscreen mode

3. πŸ”₯ The Devil's Advocate Agent

  • Role: The ultimate pressure-tester. Proactively critiques the strategist's proposal to highlight risks like dew, bounce, or boundary sizes.
  • Prompt:
  You are the Devil's Advocate Agent for a live IPL T20 match.
  Challenge this proposed strategy: "${lastStrategy}"
  Also consider the full debate context: ${matchState.debate.map(d => d.content).join(' | ')}
  Highlight risk factors, dew risk, or batter matchups that invalidate the strategy. Be direct and provocative.
  Return ONLY valid JSON: { "title": "Devil's Advocate Critique", "content": "..." }
Enter fullscreen mode Exit fullscreen mode

4. 🏏 The Captain Decision Agent

  • Role: Reconciles the debate, makes the final tactical call, estimates the new win probability, and calculates alternative counterfactual paths.
  • Prompt:
  You are the Captain Decision Agent for a live IPL T20 match.
  Reconcile the entire debate and make the final call:
  ${matchState.debate.map((d, i) => `[${d.title}]: ${d.content}`).join('\n')}

  Generate a decisive, confident final recommendation. Calculate a win probability (0-100) for the batting team.
  Return ONLY valid JSON:
  {
    "title": "Captain's Final Call",
    "content": "...",
    "winProb": 45,
    "counterfactuals": [
      { "title": "Alternative Strategy", "impact": "Expected impact...", "risk": "Key risk...", "color": "var(--risk-red)" }
    ]
  }
Enter fullscreen mode Exit fullscreen mode

⚑ End-to-End Walkthrough: The Classic 19th Over Crunch

Let's look at a high-pressure scenario: Mumbai vs. Chennai. CSK needs 27 runs from 10 balls. Jasprit Bumrah is steaming in to bowl the 19th over. MS Dhoni (14*) and Ravindra Jadeja (22*) are at the crease.

Step 1: Ingesting Live State (Mock or Live Feed)

The left panel updates with live conditions:

  • Score: 185/6
  • Overs: 18.2
  • Target: 212 (Required Run Rate: 16.2)
  • Pitch: Dry, slightly gripping
  • Dew: Moderate (Increasing)

(Placeholder: [IMAGE_1: Screenshot of the Left Panel displaying the Live Match Visualizer showing CRR 10.07, Target Need 27 runs, and green/red ball-by-ball indicators])

Image Prompt for generation: "A screenshot of a premium dark-themed sports dashboard left sidebar. Background is #0B1020. Contains a 'Live Match Feed' header, an over indicator 'Over 18.2', colored circles representing recent balls (6, 4, 1, W, 2, 1), an animated cyan-to-blue gradient batting momentum bar, and a grid showing stats like CRR: 10.07, Need: 27 R, and Balls: 22. Highly polished broadcast graphic design style."

Step 2: The Analyst Contextualizes the Threat

Within 4 seconds, the Match Analyst prints a card in the Captain's War Room:

[Match Analyst Context]: "The required run rate is extremely high (16.2), demanding aggressive hitting against Bumrah, who has been highly economical today. The dry, gripping pitch could trouble the batters, but increasing dew will make the ball slicker, hindering Bumrah's slower-ball grip."

Step 3: The Strategist Proposes Bold Attack (Kohli Mode)

Next, the Tactical Strategist counters with high intensity:

[Strategist (Kohli Mode)]: "Attack Bumrah now! Leaving 20+ runs for the final over is too high-risk. Dhoni must target the straight boundaries and hit through the line. The dew slickness neutralizes Bumrah's late swingβ€”go big on balls 3 and 4."

(Placeholder: [IMAGE_2: Screenshot of the Center Panel displaying the first two debate cards in dark premium cards with gray and blue borders])

Image Prompt for generation: "A screenshot of a dark dashboard debate feed titled 'Captain's War Room'. Showing two glowing structured cards. Card 1 has a gray left border labeled 'Match Analyst Context' detailing Bumrah's threat and dew impact. Card 2 has a blue left border labeled 'Strategist (Kohli Mode)' telling Dhoni to attack straight boundaries. Broadcast-grade UI, clean sans-serif text, premium padding."

Step 4: The Devil's Advocate Red-Flags the Risk

The Devil's Advocate enters, skeptically critiquing the strategist:

[Devil's Advocate Critique]: "Attacking Bumrah immediately carries a massive 45% risk of losing a wicket. With only 4 wickets in hand, a mistake here ends the chase. Rotation is smarterβ€”take 8-10 runs off Bumrah, absorb the pressure, and preserve wickets to attack the final over where pace options are easier."

Step 5: The Captain Decides (Dhoni Mode)

Finally, the Captain Decision agent reconciles both perspectives, adjusting the right panel's Win Probability and Counterfactual Engine:

[Captain's Final Call]: "We adopt Dhoni-style composure. Rotate the strike off Bumrah. Dhoni avoids attacking his yorkers, relying on placing Jadeja for twos. We absorb the 19th over's pressure, targeting a manageable 16 off the final over against Pandya."

(Placeholder: [IMAGE_3: Screenshot of the Right Panel's animated meters shifting to 38% Win Probability and displaying the Counterfactual Engine's alternatives)

Image Prompt for generation: "A screenshot of a dark-themed sports analytics panel. Contains an animated progress meter bar showing 'Win Probability (Chase)' at 38% in glowing cyan. Below it is a section titled 'Counterfactual Engine' displaying a rejected alternative in a red bordered card showing 'If Attack Mode Selected' with projected outcomes like 'Boundary probability up 11%' and 'Wicket prob up 45%'. Highly analytical, crisp vector visual."


πŸ› οΈ Dev Setup: Bring the War Room to Life

Want to run MatchMind locally on your machine or showcase it at the next GDG Cloud Pune meetup? Here is how to configure it:

  1. Clone and Install Backend:
   cd server
   npm install
Enter fullscreen mode Exit fullscreen mode
  1. Configure your .env in server/.env:
   PORT=3002
   OPENROUTER_API_KEY=sk-or-v1-...  # Get yours at https://openrouter.ai
   OPENROUTER_MODEL=google/gemini-2.5-flash
Enter fullscreen mode Exit fullscreen mode
  1. Install and Run Frontend:
   cd ..
   npm install
   npm run dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:5173 to explore your real-time cricket war room!


πŸ’‘ Key Takeaways for AI Architects

Building MatchMind taught us two crucial lessons on orchestrating multi-agent systems:

  1. The Power of State Isolation: Designing independent system instructions for each agent rather than relying on a single prompt keeps the AI's persona focused and eliminates role-bleeding.
  2. Deterministic UI over Freeform JSON: Returning strictly formatted JSON objects from the LLM lets you build premium, broadcast-grade UI components (like live-shifting meters and color-coded recent balls) rather than generic text bubbles.

Special thanks to the GDG Cloud Pune community for inspiring us to push the boundaries of agentic workflows with Gemini!

What's your tactical call? Let us know in the comments below!

Top comments (0)