Inspiration
Most traditional mobile games rely on static difficulty curves that quickly become predictable or frustrating. If a player is skilled, the game feels too easy; if a beginner misses a few targets, they get overwhelmed and quit. We were inspired to solve this problem by leveraging Google Gemini 2.0 Flash as an autonomous, real-time Collaborative AI Game Director. Instead of using LLMs merely for text chat, we envisioned an agent that continuously monitors live gameplay telemetry and dynamically orchestrates combat interventions to keep the player in the optimal "flow state".
What it does
ONE BULLET: AI COMMANDER is a fast-paced cyberpunk mobile arcade reaction game built with Flutter & Flame 2D.
- The Core Gameplay: Players control a mobile energy interceptor and are armed with only a single bullet. Firing the bullet ricochets off arena side-walls to eliminate invading waves, and players must maneuver their ship to catch the bullet on its return.
- Autonomous AI Director Loop: Every 5 seconds, an autonomous AI Commander evaluates live telemetry snapshots (
accuracyPercentage,streak,lives,kills,catches,misses,secondsSurvived,activePowerUps). - 5 Executable AI Tools:
spawn_enemy_wave: Spawns custom enemy waves (Speed Demons, Shielded Tanks, Zig-Zag Raiders, Bosses).set_spawn_rate: Speeds up or slows down spawn intervals dynamically.trigger_powerup: Drops emergency energy shields, time-slow items, or double points when the player is struggling.start_challenge: Issues timed precision or combo challenges for bonus points.set_ai_difficulty: Multiplies speed vectors based on live accuracy.
- AI Transparency HUD (
AiDebugPanel): A toggleable in-game log panel lets players and judges inspect real-time agent reasoning, raw JSON tool call arguments, prompt telemetry, and response mode (GEMINI_ONLINEvsLOCAL_FALLBACK). - Local Cyber Leaderboard: Persists top high scores, max streaks, dates, and agent call signs locally using device storage.
How we built it
- Frontend & Game Engine: Developed with Flutter 3.x and Flame Engine (v1.38.0) locked at 60 FPS in strict Portrait mode.
- AI Agent Orchestration: Built a custom agent loop communicating with Google Gemini 2.0 Flash API using structured JSON output schema (
responseMimeType: "application/json"). - Zero-Crash Fallback Architecture: Implemented
AiFallbackEnginethat locally evaluates telemetry offline if internet latency occurs, guaranteeing 0% game freezes or crashes. - State & Persistence: Built custom storage managers for audio settings, unlocked weapon skins (Standard, Ricochet, Plasma, Vortex), and local leaderboard rankings.
- Visual & Audio Polish: Synthesized sound effects, background music loops, camera screen shake effects, and custom canvas-painted cyberpunk neon background nebulae.
Challenges we ran into
- Decoupling Latency from 60 FPS Physics: Cloud API requests take 200–800ms, which could stutter a 60 FPS game physics loop. We solved this by running the Flame game loop deterministically on local micro-threads while triggering AI telemetry evaluations asynchronously in the background.
- Strict JSON Tool Output Enforcement: Prompt engineering Gemini 2.0 Flash to strictly follow structured tool schemas while generating concise, neon-themed 1-sentence dialogues.
- Mobile Edge-Case UX: Handling Android hardware back buttons with
PopScopeand implementing automatic game engine pause whenever an incoming phone call or background switch occurs.
Accomplishments that we're proud of
- Successfully created a closed-loop autonomous AI agent that actively manipulates game physics and mechanics rather than just chatting.
- Achieved 0 warnings and 0 errors in
flutter analyzewith 100% clean, modular Dart code. - Created a gorgeous visual design system with high-res 3D app icons and animated splash screens.
What we learned
- How to effectively implement structured JSON tool calling with Google Gemini 2.0 Flash API.
- Techniques for handling asynchronous LLM inference latency inside high-framerate 2D game loops.
- Designing transparent AI interfaces (
AiDebugPanel) that build player trust by revealing the agent's decision-making process.
What's next for One Bullet
- Multi-Agent Arena Battles: Adding two competing Gemini AI Commanders managing opposite sides of the arena in real-time.
- Google Cloud Run Backend Integration: Deploying a backend proxy for global multiplayer leaderboards and cross-device match synchronization.
- Voice Interventions: Incorporating real-time text-to-speech AI Commander voice commentary.
Built With
- agentic-ai
- ai-agent
- android
- antigravity-sdk
- arcade-game
- cyberpunk
- dart
- flame-engine
- flutter
- gemini-api
- google-cloud
- google-gemini-2.0-flash
- http
- ios
- json
- mobile-game
- rest-api
- shared-preferences
Log in or sign up for Devpost to join the conversation.