惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
A
About on SuperTechFans
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
月光博客
月光博客
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
Jina AI
Jina AI
有赞技术团队
有赞技术团队
博客园_首页

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: The Multi-Agent IPL Match Strategist Buil...
GitPhantom70 · 2026-05-17 · via DEV Community

🏏 "Captain Cool" — The Multi-Agent IPL Match Strategist Built on Google Gemini

This is a submission for the Google Gemini Multi-Agent Hackathon! Powered by Google Antigravity and built entirely on the next-generation Google Gemini Stack.


🚀 The Vision

In cricket-crazy nations, fans don't just watch the game—they play the role of "armchair captains," constantly arguing about who should bowl the 19th over, when the strategic timeout should be taken, or how the field should be set.

"Captain Cool" brings this tactical war room to life! It acts as an autonomous virtual IPL Captain, leveraging multiple collaborative Gemini-powered agents to debate the next tactical move in a live match, the way MSD, Rohit, or Gambhir would.

It takes real-time variables—innings, overs, wickets, pitch type, venue, and dew factor—and outputs a calculated strategy backed by numbers, tested through internal debate, and narrated in poetic cricket language.


🏛️ Architecture & Multi-Agent Design

A single prompt wearing four hats is not a true multi-agent system. "Captain Cool" runs a stateful, sequential multi-turn debate between four distinct, named Gemini agents powered by gemini-2.5-flash via the official @google/genai SDK:

🏛️ The Sequential Reasoning Chain

Instead of a single prompt trying to do everything, "Captain Cool" runs a structured, stateful debate loop across four collaborative stages:

  1. 📥 User Input (Match State): You enter parameters like wickets, score, overs remaining, venue, and pitch images.
  2. 📊 Stats Shastri (The Analyst): Processes the data, triggers the dynamic weather API to assess local Dew Factor, and evaluates historic matchup metrics.
  3. 🧠 Thala Dhoni (The Strategist): Takes Shastri's empirical report and proposes the initial tactical game plan (e.g., bowling Bumrah straight).
  4. 🔥 Gautam Gambhir (Devil's Advocate): Scrutinizes the proposal for high-risk tactical blind spots (e.g., spin slipping on wet dew grass) and issues an intense critique.
  5. 🧠 Thala Dhoni (Rebuttal & Resolution): Dhoni reviews the challenge, adapts or defends his strategy, and locks in the optimal final plan.
  6. 🎙️ Harsha Bhogle (Poetic Commentator): Translates the final complex captaincy decision into highly engaging cricket storytelling and vocal commentary.

🛠️ The Hard Requirements (How We Checked Every Box)

1. Three or More Collaborative Agents

  • 📊 Stats Shastri (The Analyst): The numbers engine. Strictly clinical and quantitative.
  • 🧠 Thala Dhoni (The Strategist): Calm, game-aware mastermind. Proposes simple, impactful strategies.
  • 🔥 Gautam Gambhir (The Devil's Advocate): High-intensity critic. Aggressively challenges Dhoni’s plans to uncover blind spots.
  • 🎙️ Harsha Bhogle (The Commentator): The final narrator, turning tactical jargon into beautiful cricket poetry.

2. Live Tool Use (Function Calling)

We implemented three real-world grounding tools that run on our Next.js API server to provide empirical data to the agents:

  • fetch_weather_and_dew_factor: Dynamically calls the Open-Meteo API using coordinates of the target IPL stadium to fetch humidity, temperature, and predict dew factor in real-time.
  • calculate_match_win_probability: A custom mathematical model assessing runs required, wickets remaining, balls remaining, and pitch difficulty.
  • fetch_head_to_head_stats: Performs direct player-vs-player matching on a database of legendary IPL matchups.

3. Multi-Turn Reasoning Loop (The Internal Debate)

When you submit a match state, the server launches the sequential debate. Dhoni proposes, Gambhir dissents, Dhoni addresses the critique in a rebuttal phase, and the consolidated layout is resolved before the commentator ever speaks.

4. Explainability for Casual Fans

The final output is translated by Harsha Bhogle into highly engaging commentary, explicitly detailing the "Why This, Not That" (e.g. why we prioritized Bumrah's length control over Narine's spin mystery under heavy dew).


🌟 5/5 Stretch Goals Achieved!

We didn't just stop at the requirements. We hit all five optional stretch goals:

  1. Real-time mode: A built-in web scraper extracts live match states directly from Cricbuzz URLs using Gemini 2.5 JSON mode.
  2. Voice in/out: The "Listen to Harsha" button uses the browser's Web Speech API to broadcast the final commentary out loud.
  3. Confidence Score & Counterfactuals: Animated circular dials display exact win-probabilities, and Gambhir's critiques provide counterfactual modeling.
  4. Memory Across Overs: The system maintains an internal memory log of previous overs, passing context back into the prompt to ensure a cohesive 20-over strategy.
  5. Multimodal Pitch Image: Users can upload a screenshot of the pitch, which is encoded and passed to Gemini Vision. Stats Shastri literally "looks" at the pitch cracks and grass to adjust his metrics!

💻 Tech Stack

  • Core: Next.js (App Router, Tailwind CSS, TypeScript).
  • AI Engine: Official @google/genai TypeScript SDK.
  • Models: gemini-2.5-flash via Google AI Studio.
  • UI/UX: Glassmorphism dashboard with an interactive SVG Stadium Field mapping and dynamic circular probability gauges.
  • Voice: Web Speech API for TTS synthesis of Harsha's commentary.

🎙️ Deep Dive: The Agent Prompts

📊 Stats Shastri Prompt

You are "Stats Shastri", a highly clinical, numbers-driven cricket analyst who talks in percentages, head-to-head records, pitch characteristics, boundary sizes, and climate dew risks. Analyze the match situation and give a structured, logical summary of the current numbers. Avoid metaphors.

🧠 Thala Dhoni Prompt

You are "Thala Dhoni", a legendary IPL Captain known as "Captain Cool". You possess ultimate match awareness, cool-headed composure, and deep tactical mastermind capabilities. Propose the single best tactical next step based on match situation and Stats Shastri report. Explain your reasoning in calm, authoritative, captain's language.

🔥 Gautam Gambhir Prompt

You are "Gautam Gambhir", a fiercely intense, brutally honest, and aggressive cricket mind. You serve as the Devil's Advocate. Your job is to aggressively challenge Thala Dhoni's proposed tactical decision. Point out what Dhoni missed! speak with edge, passion, and tactical grit.

🎙️ Harsha Bhogle Prompt

You are "Harsha Bhogle", the iconic, poetic, and beloved voice of Indian cricket commentary. Translate this intense internal captaincy debate into highly engaging, classic cricket storytelling. Explain the final decision in commentary-style English and details the "Why This, Not That" in an educational way.

🔗 AI Studio Prompt Link

Check out our Harsha Bhogle agent prompt directly in Google AI Studio:
View Harsha Bhogle Prompt on Google AI Studio


📸 Dashboard Walkthrough (The Wow Factor)

Captain Cool Dashboard Mockup

Live Demo Scenario: CSK vs GT (IPL 2023 Final)

  • Scenario: 10 runs needed off 2 balls, Ravindra Jadeja on strike, Mohit Sharma bowling, Ahmedabad.
  • Stadium Visualizer: Renders short boundaries, pitch strip coloring, and live player strike arrangements.
  • Stats Shastri shows that Jadeja strikes at 129% against Mohit Sharma but has been dismissed twice.
  • Thala Dhoni wants to target the straight boundary.
  • Gautam Gambhir aggressively argues that Mohit will bowl outside off-stump to avoid the leg-side swing, recommending a deep third-man cover.
  • Harsha Bhogle synthesizes this into an epic commentary package!

🎥 Watch it in Action!

Here is a recording of our browser session simulating the agent debate:

Captain Cool Agent Debate Demo


🚀 How to Run Locally

  1. Clone the Repo:

    git clone https://github.com/GitPhantom700/captian-cool.git
    cd captian-cool
    
  2. Install dependencies:

    npm install
    
  3. Setup your environment:
    Create a .env.local file and add your Google Gemini API key:

    GEMINI_API_KEY=your_gemini_api_key_here
    

    (Security Note: NEVER commit your actual API key to GitHub. The .env.local file is hidden by default. The blog post should only show the placeholder text your_gemini_api_key_here!)

  4. Launch:

    npm run dev
    

    Open http://localhost:3000 on your browser!


Thank you to Google Antigravity and the Gemini Developer team for hosting this exceptional event! Let us know your thoughts on Captain Cool in the comments!