DEV Community

Aditya Anarase
Aditya Anarase

Posted on

Captain Cool AI — Building a Multi-Agent IPL Strategy Engine with Google Gemini 2.5

Captain Cool AI — Building a Multi-Agent IPL Strategy Engine with Google Gemini 2.5

Cricket is a captain’s game.

In the IPL, tactical decisions change matches ball-by-ball:

  • Who bowls the next over?
  • Should spin continue under dew?
  • When should the Impact Player be used?
  • Should the captain attack or defend the boundary?

We wanted to build an AI system that thinks like a real IPL captain.

So we built Captain Cool AI — a multi-agent IPL tactical command center powered entirely by the Google Gemini ecosystem.

Instead of creating a generic cricket chatbot, we designed a system where multiple AI agents debate strategy like a real dugout before committing to a final tactical call.


The Idea

The goal was simple:

Simulate how elite IPL captains think under pressure.

Captain Cool AI allows users to input:

  • current score
  • overs
  • wickets
  • target
  • pitch conditions
  • dew factor
  • bowling options
  • batting pair

The system then:

  1. Runs a multi-agent tactical debate
  2. Challenges decisions internally
  3. Calculates probabilities
  4. Explains the final strategy in authentic cricket language

The result feels less like an AI assistant and more like an IPL strategy war room.


Tech Stack

We built the entire system on Google’s AI ecosystem.

Core Stack

  • Next.js
  • TailwindCSS
  • FastAPI
  • Google Gemini 2.5 Flash
  • Google Gemini 2.5 Pro
  • Google ADK
  • Gemini Function Calling

Architecture Overview

Captain Cool AI uses a multi-agent architecture where every agent has:

  • its own role
  • its own system prompt
  • independent Gemini calls
  • tactical specialization
  • shared contextual memory

The 4 AI Agents

1. Match Analyst Agent

The Match Analyst acts like a Moneyball-style cricket strategist.

Responsibilities:

  • analyze batter vs bowler matchups
  • calculate pressure index
  • evaluate pitch behavior
  • estimate win probability
  • identify tactical trends

Example:

“Hardik Pandya strikes at 192 against pace-on deliveries in death overs but drops significantly against wide yorkers.”


2. Tactical Captain Agent

This agent behaves like a calm IPL captain under pressure.

Responsibilities:

  • decide bowling changes
  • recommend field placements
  • suggest Impact Player timing
  • manage over-by-over tactics

Example:

“Bring Pathirana now and force Hardik to access the off-side boundary.”


3. Devil’s Advocate Agent

This was the most important part of the system.

Instead of blindly agreeing, this agent aggressively challenges tactical decisions.

Responsibilities:

  • expose tactical risks
  • question emotional decisions
  • propose alternative strategies
  • force revisions

Example:

“Saving Rashid for over 19 is dangerous because dew will reduce grip significantly.”

This creates genuine agentic behavior instead of fake multi-role prompting.


4. Commentary Expert Agent

The final agent explains the tactical decision like a live cricket commentator.

Responsibilities:

  • convert tactical reasoning into fan-friendly commentary
  • explain why-this-not-that
  • summarize risk/reward tradeoffs

Example:

“This is classic death-over manipulation. The captain is forcing the batter to hit against the angle under pressure.”


Multi-Agent Tactical Debate

The core innovation was the debate loop.

Instead of using a single Gemini prompt pretending to be multiple agents, we implemented a real reasoning workflow:

  1. Match Analyst evaluates conditions
  2. Tactical Captain proposes a strategy
  3. Devil’s Advocate critiques the plan
  4. Tactical Captain revises or defends
  5. Commentary Expert explains the final decision

This created tactical discussions that felt surprisingly authentic.


Shared Match Memory

We implemented shared contextual memory across all agents.

The system tracks:

  • previous overs
  • batter momentum
  • bowler rhythm
  • yorker success rate
  • pressure moments
  • tactical patterns

This allows agents to reference earlier events naturally.

Example:

“Siraj missed yorkers in the previous over, so the captain should avoid repeating the same plan.”


Gemini Tool Calling

To make the system truly agentic, we integrated Gemini function calling with tactical tools.

Tools Used

Win Probability Engine

Calculates:

  • win probability
  • projected score
  • pressure index
  • momentum shifts

Matchup Analyzer

Evaluates:

  • batter vs bowler records
  • spin vs pace effectiveness
  • death-over strike rates

Pitch & Dew Analyzer

Analyzes:

  • dew conditions
  • pitch slowdown
  • venue behavior

These tools allowed agents to reason using real tactical data instead of static prompting.


Live Match Scraper

One of the most exciting features was the live match scraper.

Users can paste:

  • Cricbuzz URLs
  • ESPN Cricinfo URLs

The system then:

  1. fetches live match content
  2. extracts score/state using Gemini
  3. auto-populates the tactical dashboard
  4. starts tactical analysis instantly

This made the experience feel like a real AI-powered IPL command center.


Tactical Realism

We wanted every output to feel like real cricket intelligence.

So the system generates:

  • bowling changes
  • field placements
  • tactical intent
  • counterfactual reasoning
  • alternative rejected strategies

Example:

“Bowling Rashid now improves win probability from 61% to 68% because dew may reduce spin grip later.”

Field setups are also generated dynamically:

  • deep square leg
  • long-off back
  • third-man fine
  • cover inside the ring

This made the strategies feel much closer to actual IPL captaincy.


Captaincy Personality Modes

We added different captain personalities to simulate tactical styles.

Modes:

  • Dhoni Mode
  • Rohit Mode
  • Gambhir Mode
  • Cummins Mode

Each mode changes:

  • aggression level
  • bowling strategy
  • field placement logic
  • tactical tone
  • risk appetite

This added personality and realism to the system.


Frontend Experience

The UI was designed to feel like:

an IPL tactical command center

instead of:

a generic AI chatbot.

We built:

  • live tactical debate timeline
  • streaming agent responses
  • confidence meters
  • win probability cards
  • premium dark sports analytics UI
  • command-center aesthetics

The goal was immersion and realism.


Example Tactical Scenario

Scenario:

  • MI need 24 off 10
  • Hardik Pandya on strike
  • Heavy dew
  • Pathirana has one over remaining

Tactical Captain

“Bring Pathirana now with wide yorkers.”

Devil’s Advocate

“Hardik targets pace-on deliveries. Jadeja may force mistimed lofts.”

Final Decision

“Use Pathirana with deep third and long-off protection.”

Commentary Expert

“This is classic death-over manipulation under pressure.”


Challenges

Some of the biggest engineering challenges included:

  • creating believable tactical debate
  • maintaining shared memory
  • coordinating multiple Gemini agents
  • balancing realism with speed
  • designing cricket-authentic explanations
  • building smooth orchestration workflows

Final Thoughts

Captain Cool AI was built around one question:

“What would a great IPL captain do next?”

By combining:

  • Google Gemini 2.5
  • multi-agent orchestration
  • tactical explainability
  • live match parsing
  • shared contextual memory

we created an AI-powered IPL strategy engine capable of debating cricket tactics like a real IPL dugout.

This project showed how agentic AI systems can move far beyond chatbots into collaborative tactical intelligence systems.


GitHub Repository

https://github.com/Aditya-Anarse/captain-cool-aii.git


Built With

  • Google Gemini 2.5
  • Google ADK
  • Next.js
  • FastAPI
  • TailwindCSS
  • Gemini Function Calling

Top comments (0)