ๆƒฏๆ€ง่šๅˆ ้ซ˜ๆ•ˆ่ฟฝ่ธชๅ’Œ้˜…่ฏปไฝ ๆ„Ÿๅ…ด่ถฃ็š„ๅšๅฎขใ€ๆ–ฐ้—ปใ€็ง‘ๆŠ€่ต„่ฎฏ
้˜…่ฏปๅŽŸๆ–‡ ๅœจๆƒฏๆ€ง่šๅˆไธญๆ‰“ๅผ€

ๆŽจ่่ฎข้˜…ๆบ

้’›ๅช’ไฝ“๏ผšๅผ•้ข†ๆœชๆฅๅ•†ไธšไธŽ็”Ÿๆดปๆ–ฐ็Ÿฅ
้’›ๅช’ไฝ“๏ผšๅผ•้ข†ๆœชๆฅๅ•†ไธšไธŽ็”Ÿๆดปๆ–ฐ็Ÿฅ
MongoDB | Blog
MongoDB | Blog
ๅš
ๅšๅฎขๅ›ญ_้ฆ–้กต
ๅš
ๅšๅฎขๅ›ญ - ไธ‰็”Ÿ็ŸณไธŠ(FineUIๆŽงไปถ)
ๅš
ๅšๅฎขๅ›ญ - ่‚ๅพฎไธœ
B
Blog RSS Feed
D
Docker
ITไน‹ๅฎถ
ITไน‹ๅฎถ
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
OSCHINA ็คพๅŒบๆœ€ๆ–ฐๆ–ฐ้—ป
OSCHINA ็คพๅŒบๆœ€ๆ–ฐๆ–ฐ้—ป
้˜ฎไธ€ๅณฐ็š„็ฝ‘็ปœๆ—ฅๅฟ—
้˜ฎไธ€ๅณฐ็š„็ฝ‘็ปœๆ—ฅๅฟ—
็ฝ—
็ฝ—็ฃŠ็š„็‹ฌ็ซ‹ๅšๅฎข
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
V
V2EX
้‡
้‡ๅญไฝ
้›ทๅณฐ็ฝ‘
้›ทๅณฐ็ฝ‘
ๆœˆๅ…‰ๅšๅฎข
ๆœˆๅ…‰ๅšๅฎข
ไบ‘้ฃŽ็š„ BLOG
ไบ‘้ฃŽ็š„ BLOG
ๅฅ‡ๅฎขSolidotโ€“ไผ ้€’ๆœ€ๆ–ฐ็ง‘ๆŠ€ๆƒ…ๆŠฅ
ๅฅ‡ๅฎขSolidotโ€“ไผ ้€’ๆœ€ๆ–ฐ็ง‘ๆŠ€ๆƒ…ๆŠฅ
T
Tailwind CSS Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Donโ€™t Fail โ€” They Drift Spilling beans for how i learn for exam๐Ÿ˜"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" โ€” What Actually Happened Comfy Cloudโ€™s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions โ€” here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components โ€” Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cรณmo construรญ un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 ๐Ÿš€ I Built an Ethical Hacking Scanner Tool โ€“ Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points โ€” Here's What I Found About How Markets Really Move EcoTrack AI โ€” Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
# ๐Ÿ Captain Cool โ€” I Built a Multi-Agent IPL Match Strate...
Bhagyashree ยท 2026-05-17 ยท via DEV Community

๐Ÿ Captain Cool โ€” I Built a Multi-Agent IPL Match Strategist on Google Gemini in 3 Hours

"What would Dhoni do here?" โ€” Every cricket fan, every tense over, ever.

I just built Captain Cool โ€” an agentic AI system that thinks like an IPL captain. You feed it the live match state, and it debates internally before giving you the next tactical call: who bowls, who bats, when to take the timeout, when to unleash the Impact Player.

Here's how I built it in 3 hours for the GDC hackathon, entirely on the Google Gemini stack.


๐ŸŽฏ The Problem

Cricket captaincy is one of the most cognitively demanding jobs in sport. In a T20 match, a captain makes dozens of split-second decisions:

  • Which bowler handles the left-hander with dew on the ball?
  • Do you burn your Impact Player in the 14th over or save for death?
  • Is this the right moment for a strategic timeout to break the momentum?

No AI assistant I'd seen could reason about this the way a real captain does โ€” with context, dissent, and cricket language. So I built one.


๐Ÿ—๏ธ Architecture Overview

User Input (Match State)
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              ORCHESTRATOR LAYER                 โ”‚
โ”‚         (Gemini 2.5 Flash Coordinator)          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚              โ”‚              โ”‚
       โ–ผ              โ–ผ              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  STATS   โ”‚  โ”‚ STRATEGIST โ”‚  โ”‚ DEVIL'S      โ”‚
โ”‚ ANALYST  โ”‚  โ”‚   AGENT    โ”‚  โ”‚ ADVOCATE     โ”‚
โ”‚  AGENT   โ”‚  โ”‚            โ”‚  โ”‚   AGENT      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚             โ”‚                โ”‚
       โ”‚     Live Cricket Stats API   โ”‚
       โ”‚     (Cricbuzz / ESPN)        โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
                     โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚  COMMENTATOR   โ”‚
            โ”‚    AGENT       โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
                     โ–ผ
         Final Decision + Debate + Commentary

Enter fullscreen mode Exit fullscreen mode

Four named Gemini-powered agents, each with its own system prompt, each doing a real job.


๐Ÿค– The Four Agents

1. ๐Ÿ“Š Stats Analyst Agent

Role: Pulls real match data and player statistics, then summarises what the numbers say.

System Prompt:

You are a cricket data analyst with access to live match feeds and historical player stats.
Your job is to:
- Retrieve current bowler economy rates, wickets taken, overs remaining
- Look up batter vs bowler matchup history (e.g., "Bumrah vs left-handers in death overs")
- Report the pitch conditions, dew factor probability, and venue history
- Output a structured stat summary โ€” no opinions, just facts and numbers

Speak like Jarrod Kimber, not a spreadsheet. Make the numbers tell a story.

Enter fullscreen mode Exit fullscreen mode

Tool Call: This agent makes a live Cricbuzz/ESPN API call to fetch real match state โ€” player stats, current economy, wickets, and over-by-over data. No hardcoded JSON.

// Gemini function calling โ€” Stats Analyst tool definition
const statsToolDeclaration = {
  name: "get_live_match_stats",
  description: "Fetches live match data, player stats, and historical matchup records from Cricbuzz API",
  parameters: {
    type: "object",
    properties: {
      match_id: { type: "string", description: "Live match ID from Cricbuzz" },
      player_ids: { 
        type: "array", 
        items: { type: "string" },
        description: "Player IDs to fetch matchup history for"
      },
      stat_types: {
        type: "array",
        items: { type: "string" },
        description: "Types of stats needed: economy, strike_rate, matchup_history, pitch_report"
      }
    },
    required: ["match_id"]
  }
};

Enter fullscreen mode Exit fullscreen mode


2. ๐Ÿง  Strategist Agent

Role: Takes the stats and proposes the next tactical decision, fully reasoned.

System Prompt:

You are a seasoned IPL captain with 10 years of T20 experience โ€” think MS Dhoni's calm and Rohit Sharma's pattern recognition.

Given the stat summary from the Analyst, propose ONE clear tactical decision for the next over:
- Name the bowler and explain why (matchup, form, conditions, overs remaining)
- Or name the incoming batter and the role they should play (pinch-hit, anchor, accelerate)
- Or call for the strategic timeout and explain the momentum reason

Speak in cricket language. Reference the pitch, the matchup, the phase of game.
Never say "the model suggests" โ€” you ARE the captain.
Format: Decision โ†’ Reasoning (3-4 sentences) โ†’ Confidence level (High / Medium / Calculated Gamble)

Enter fullscreen mode Exit fullscreen mode


3. ๐Ÿ˜ˆ Devil's Advocate Agent

Role: Challenges the Strategist's call. Must find the strongest counter-argument.

System Prompt:

You are the experienced senior pro in the dressing room who's seen captains make the same mistake for 15 years.

The Strategist has just made a call. Your job is to find the single most dangerous flaw in that logic:
- Is there a matchup problem they're ignoring?
- Is the bowler carrying fatigue or a niggle?
- Does the dew factor change everything in 3 overs?
- Is the batter choice leaving the tail exposed too early?

You MUST disagree with at least part of the decision. If the decision is sound, find the edge case that could still blow it up.
Format: Objection โ†’ Why it matters โ†’ Alternative suggestion
Do not be polite. Be honest. Lives (or at least, run-rate) are at stake.

Enter fullscreen mode Exit fullscreen mode


4. ๐ŸŽ™๏ธ Commentator Agent

Role: Takes the final decision (after debate) and translates it into broadcast-ready cricket talk.

System Prompt:

You are Harsha Bhogle and Ravi Shastri had a child who grew up to understand data.

The captain's decision has been made, the debate has happened. Now dramatise it.
- Open with the tension of the moment
- Deliver the decision like a reveal
- Explain the dissenting view that was considered and why the captain overruled it
- End with what it means for the match โ€” what must happen for this call to look right in 20 overs

Write it as commentary, not a report. Use cricket idioms. Reference iconic moments if relevant.
Maximum 200 words. Every word must earn its place.

Enter fullscreen mode Exit fullscreen mode


๐Ÿ”„ The Multi-Turn Reasoning Loop

This is the core of what makes Captain Cool genuinely agentic โ€” not a single Gemini call, but a structured debate:

Round 1: Stats Analyst โ†’ fetches live data โ†’ outputs stat brief
Round 2: Strategist โ†’ reads stat brief โ†’ proposes decision
Round 3: Devil's Advocate โ†’ reads Strategist's proposal โ†’ challenges it
Round 4: Strategist โ†’ reads challenge โ†’ DEFENDS or REVISES the call
Round 5: Commentator โ†’ reads full debate โ†’ produces final output

Enter fullscreen mode Exit fullscreen mode

The output always shows this back-and-forth. You see the Strategist's original call, the Devil's Advocate's objection, and the Strategist's final response โ€” then the Commentator's broadcast version.

Here's a real example from a Mumbai Indians vs CSK scenario:


๐Ÿงช Live Match Scenario Walkthrough

Input:

Innings: 2 | Over: 16 | Score: CSK 134/3 (need 49 off 24)
Batters: Dhoni (strike, 12 off 8) + Jadeja (non-striker, 34 off 22)
MI Bowlers remaining: Bumrah (2 overs), Pollard (0), Chahal (1), Boult (0)
Pitch: Wankhede, flat, heavy dew setting in
Impact Player: MI yet to use
Required RR: 12.25

Enter fullscreen mode Exit fullscreen mode

Stats Analyst output:

Bumrah in death overs this season: Economy 7.8, 4 wickets in 38 balls. vs RHB in dew: Economy creeps to 8.9. Dhoni vs Bumrah: 6 balls, 3 runs, 1 dismissal โ€” but all on dry pitches. Jadeja vs Bumrah: 11 balls, 14 runs, 0 dismissals. Wankhede dew historically kicks in ball 95+. We're at ball 96. The ball is already slipping.

Strategist proposes:

Bowl Chahal now, save both Bumrah overs for 18 and 20. Dhoni reads Bumrah. He'll take the single and farm Jadeja against pace. Chahal on a wet ball is risky but Jadeja against leg-spin has a SR of 88 โ€” well below his average. One wicket here and CSK lose the finisher rotation. Confidence: Calculated Gamble.

Devil's Advocate objects:

Chahal in dew at Wankhede is a half-tracker machine. That flat Wankhede surface with moisture means the ball won't grip. Jadeja will step down and slog him over mid-on in the first 3 balls. And if Dhoni gets 2 singles, Jadeja is on strike for all 6 โ€” exactly what CSK want. Bowl Bumrah now while Dhoni is set but the match is still alive. Don't wait for over 20 when dew is maximal.

Strategist defends:

The dew concern is valid, but Bumrah in over 16 against a settled Dhoni is still a better matchup than Bumrah in over 20 against a panicking lower order. CSK need 12+ an over โ€” Chahal goes for 10, we're still alive. If Dhoni smashes Bumrah for 18 in over 20, we have nobody. Hold Bumrah. Decision stands.

Commentator output:

The Wankhede dew is the third batter in this match now โ€” invisible, slippery, tilting everything. Rohit goes with Chahal, and the dressing room debate was fierce. Bumrah wanted the ball. The analytics said wait. And Rohit, ever the pragmatist, split the difference โ€” he's backing his leggie to take the one wicket that changes everything. Jadeja's weakness against wrist spin is buried in the numbers, but Rohit's been watching it all match. If Chahal can't grip it by ball 4, Bumrah's warming up in the outfield. This is captaincy on a knife's edge โ€” one bad ball from a rout, one wicket from a thriller.


๐Ÿ› ๏ธ Tech Stack

Component Tool Used
LLM backbone Gemini 2.5 Flash (gemini-2.5-flash)
Multi-agent framework Google ADK (Agent Development Kit)
Tool use Gemini function calling
Live data Cricbuzz API (via RapidAPI)
Prompt prototyping Google AI Studio
IDE Google Antigravity (vibe-coded the whole thing)
Frontend React + Tailwind

๐Ÿงฉ Why Google ADK Made This Possible

The Agent Development Kit made orchestrating the debate loop dramatically cleaner than rolling it myself. Each agent is defined with its own system prompt, tool access, and output schema. ADK handles:

  • Message passing between agents in sequence
  • Tool call routing (Stats Analyst is the only agent with API access)
  • Context window management across turns (no stale state)

The .antigravity/ folder in the repo has the full agent trace โ€” you can see each agent's reasoning turn-by-turn.


๐Ÿ’ก What I Learned

1. System prompt specificity is everything. "Be a cricket analyst" gave generic output. "You are Jarrod Kimber, not a spreadsheet โ€” make the numbers tell a story" gave something worth reading.

2. The Devil's Advocate agent is the most valuable. Without it, the Strategist just confidently produces the obvious answer. Forced dissent surfaced three edge cases I hadn't considered during testing.

3. Real API data changes the output quality dramatically. When Bumrah's actual dew-condition economy rate was pulled live (not hardcoded), the Strategist's reasoning became notably more specific and accurate.

4. Dew factor is always the answer. I'm convinced 60% of cricket decisions reduce to dew factor at some point.


๐Ÿš€ What's Next (Stretch Goals I Want to Build)

  • Real-time mode โ€” paste a Cricbuzz URL, Gemini scrapes the live state itself
  • Voice output โ€” the Commentator agent speaks via Gemini Live API + Web Speech
  • Confidence scores + counterfactuals โ€” "if you'd bowled Bumrah now, win prob drops 11%"
  • Memory across overs โ€” Gemini context caching so it remembers the full match arc

๐Ÿ“ Links


Final Thought

Cricket is a captain's game. The data is the dressing room brief. The debate is the senior pro in your ear. And the Commentator is the moment you walk out of the dugout and own the call.

Captain Cool is that whole dressing room, in your browser, in real time.

Built on Gemini. In 3 hours. ๐Ÿ†


Built for the GDC IPL AI Hackathon | #GeminiAPI #GoogleADK #CricketAI #IPL2025 #BuiltWithGemini