DEV Community

Sohan Mirajkar
Sohan Mirajkar

Posted on

Building "Captain Cool": A Multi-Agent AI War Room for T20 IPL Cricket

T20 cricket, especially the IPL, is a game of microscopic margins. A match can flip in a single over, and the pressure on the captain is immense. Should you bowl your strike bowler now to break a partnership, or save him for the death overs? Is the dew factor bad enough to bring in a spinner?

If you ask a standard AI chatbot what to do, you usually get generic advice like, "Bowl a good line and length and set fielding traps." That doesn't help when an explosive batter is striking at 200 and you only have one over of your best bowler left.

To solve this, I built Captain Cool—an AI war room powered by Google's Gemini. Instead of relying on a single prompt to generate a generic answer, it uses a multi-agent system to turn live match states into clear, hotly debated, and actionable tactical calls.

Here is a step-by-step breakdown of how this virtual cricket dugout works behind the scenes.


Step 1: Gathering the Ground Truth

Before any AI can make a strategic decision, it needs perfect situational awareness.

The system acts as the eyes and ears of the captain. It pulls in the exact match scenario—either via live data integration or manual input. This isn't just the score; it includes the current over, the exact batters at the crease, the remaining overs for specific bowlers, the target run rate, and even whether the Impact Player is still available.

This rich, highly specific context is packaged up and handed off to the first AI agent.

Step 2: The Data Analyst (Agent Gamma)

In a real dugout, the first person the coach turns to is the data analyst. In our system, this is Stats Analyst Gamma.

Gamma’s job is strictly analytical. Instead of guessing, Gamma is equipped with real-world tool-calling capabilities. It uses an external weather API to check the real-time conditions at the specific venue, paying special attention to the dew point—a critical factor for gripping the ball in night matches. It also calculates the mathematical win probability based on the current score and target.

Gamma then compiles a concise, statistical brief, setting the factual stage for the strategists.

Step 3: The Primary Strategist (Agent Alpha)

Once the data is ready, it is passed to Strategist Alpha.

Alpha is designed with a very specific persona: a decisive, uncompromising tactician. Alpha reads Gamma’s statistical brief and the current match state, and formulates an initial game plan.

The strict rule for Alpha is that it cannot sit on the fence. It must propose one committed, aggressive tactical move for the upcoming over from the captain's perspective—whether that is bringing on a spinner to exploit a matchup or setting a specific field for a bouncer strategy.

Step 4: The Devil's Advocate (Agent Beta)

This is where the magic happens. The first idea is rarely the perfect idea, so Alpha’s plan is immediately handed over to Devil’s Advocate Beta.

Beta is programmed to be highly critical. Its entire purpose is to read Alpha’s proposed strategy and violently attack its weaknesses. Beta will point out if Alpha ignored the dew factor, if a proposed bowler has a terrible historical matchup against the current striker, or if the plan leaves the team vulnerable in the final overs.

After tearing down the initial plan, Beta proposes what it believes is the strongest, most resilient alternative.

Step 5: The Final Verdict

The debate loop concludes by passing Beta’s scathing critique back to Strategist Alpha.

Alpha must read the critique and make a final call. It has two choices: stubbornly defend the original plan by justifying why the risks are worth taking, or pivot and revise the strategy based on Beta’s valid points.

The output is then translated into a highly readable, captain-friendly final decision that is immediately actionable.


The "Glass Box" Experience

To make this useful, the frontend UI doesn't just show you the final answer. It exposes the entire "war room" debate.

As a user, you get to read Gamma's stats, Alpha's bold initial idea, Beta's brutal critique, and the final resolution. This transparency completely changes the user experience. You aren't just getting an AI's guess; you are watching an AI critically reason through a complex sports scenario, building trust in the final tactical call.

Building Captain Cool proved that by breaking a complex problem down and assigning it to specialized, debating AI personas, you can elevate an LLM from a generic chatbot into a deeply analytical sports strategist.

(If you're interested in the architecture or the prompt engineering used to build these agents, you can check out the full project on GitHub under soh4n/Captain-Cool)

Top comments (0)