BlackSwan: A Lightweight Competitive Mobility Simulator with Hybrid Intelligence
Quick Navigation
- Inspiration — Why we're building this
- Why Existing Solutions Miss the Mark — Gap analysis
- What It Does — System overview & architecture
- What Makes This Different — Our USPs
- A Real Race Scenario — Example walkthrough
- How We'll Build It — Technical implementation
- Challenges We Expect — Risk mitigation
- What We Learned — Key insights
Inspiration
Most mobility simulators today are really good at physics and pathfinding, but they're terrible at making strategic decisions. When you watch Formula E or MotoGP, the exciting part isn't just the driving, it's the strategy. When to overtake, how to manage energy, whether to risk an aggressive move or play it safe.
We started thinking: what if racing agents could actually think about these decisions, not just react to them?
That's BlackSwan. Instead of building yet another traffic simulator, we're building something that understands competition, overtaking, risk management, pit strategy, and adapting to chaos when things go wrong.
Why Existing Solutions Miss the Mark
Here's the problem with current simulators:
- SUMO/CARLA: Great physics, zero racing intelligence
- AirSim: Solid for drones, but no competitive dynamics
- Grand Prix Manager games: Strategic but not AI-driven or research-grade
- OpenAI Gym Racing: Pure reflexes, no strategic thinking
- Academic MARL papers: Mostly about cooperation, not competition
None of them combine lightweight performance with actual racing strategy. That's where BlackSwan comes in.
What It Does
BlackSwan uses a hybrid architecture that's intentionally unbalanced: 99% fast reflexes, 1% strategic thinking.

The Fast Part: Tactical Reflexes (MARL)
Every agent uses PPO-based reinforcement learning for moment-to-moment decisions—steering, braking, acceleration, collision avoidance. This runs every frame, 30-60 times per second, keeping the simulation smooth even with 100+ agents.
The Smart Part: Strategic Cortex (LLM)
Here's where it gets interesting. The LLM doesn't run constantly—that would be way too slow. Instead, it activates only when agents face genuine strategic dilemmas:
- Stuck behind a crash with multiple route options
- Energy dropping critically low mid-race
- Perfect overtaking opportunity but risky
- Pit stop timing decision
- Multi-agent incident blocking the track
When triggered, the agent gets a context-rich prompt about its situation and returns a structured decision:
{
"trigger": "overtake_opportunity",
"reasoning": "Leader showing lift-and-coast behavior, 5% less energy",
"strategy": "aggressive_late_braking_turn_1",
"risk": "medium",
"success_probability": "68%"
}
This happens maybe 3-7 times per agent during a 30-minute race. The rest of the time? Pure fast reflexes.
Live Racing Leaderboard
Here's what it shows in real-time (Representation only, actual will be different and in a good way):
╔════════════════════════════════════════════════════════════╗
║ BLACKSWAN — FORMULA E MONACO E-PRIX ║
║ Lap 23/45 • Race Time: 18:42.3 ║
╠═════╦═════════╦═══════════╦═════════╦═════════╦═══════════╣
║ POS ║ AGENT ║ GAP ║ LAST LAP║ ENERGY ║ STATUS ║
╠═════╬═════════╬═══════════╬═════════╬═════════╬═══════════╣
║ 1 ║ AGT-07 ║ LEADER ║ 1:12.34 ║ 51% ████║ RACING ║
║ 2 ║ AGT-12 ║ +1.8s ║ 1:12.51 ║ 38% ███ ║ ATTACK ║
║ 3 ║ AGT-19 ║ +4.2s ║ 1:12.88 ║ 44% ███ ║ RACING ║
║ 4 ║ AGT-03 ║ +6.7s ║ 1:13.02 ║ 47% ███ ║ CONSERVE ║
╚═════╩═════════╩═══════════╩═════════╩═════════╩═══════════╝
Recent Strategic Decisions:
• Lap 22: AGT-12 → "Plan aggressive overtake" (68% confidence)
• Lap 21: AGT-03 → "Energy conservation mode"
• Lap 19: AGT-14 → Attack Mode activated
You get race positions, time gaps, lap times, energy levels, overtake counts, and—crucially—you can see when agents are making strategic decisions versus just racing normally.
The Cognition Window
This is our favorite part. Click any agent and you see exactly what it's thinking. The prompt it received, its reasoning process, the decision it made, and whether it worked. No more black-box AI, you can literally audit why an agent chose to pit early or attempt a risky overtake.
What Makes This Different
It's actually lightweight. We're not running LLMs every frame. Strategic thinking happens less than once per minute per agent. The simulation runs at 30-60 FPS with 100+ agents because 99% of the time it's just fast MARL reflexes.
It understands competition. Agents don't cooperate or form convoys—they race. They learn drafting, late braking, defensive blocking, energy management, and risk-adjusted aggression. The strategies that emerge are competitive, not social.
You can see the thinking. The cognition window shows you the exact moment an agent switched from reflexes to strategic reasoning, what it considered, and what it chose. This transparency makes the AI trustworthy and debuggable.
It works across racing domains. Formula E energy management is different from MotoGP tire strategy, which is different from drone battery optimization. We've designed the system to handle all of these with domain-specific modules.
Proof, not promises. We built a split-screen mode where you can watch baseline MARL agents versus BlackSwan hybrids handle the same incidents.
A Real Race Scenario
Let me walk you through what actually happens in a simulated Formula E race (All the stats used below are dummy numbers just for illustration, Based on past data.):
Laps 1-10 are straightforward racing. Pure MARL reflexes, zero LLM triggers, 61 FPS average. Eight overtakes happen based on positioning and momentum.
Lap 11: A crash blocks Turn 7. Six agents approaching at speed. All six trigger strategic reasoning simultaneously. Some choose to brake and wait (slower but safer), others reroute through the pit lane (faster but costs track position). Different strategies, different outcomes. The agent that chose pit lane reroute dropped from P3 to P5 but kept racing—better than getting stuck behind debris.
Lap 18: The race leader hits 42% energy with 27 laps to go. The math doesn't work—they'll run out before the finish. Strategic reasoning kicks in: "Need to save 0.4% per lap, accept pace drop, medium risk of losing P1." They implement lift-and-coast in certain sectors. Their lap time drops by 0.3 seconds, but they'll actually finish the race.
Lap 23: The P2 agent notices the leader is energy-saving and vulnerable. Their strategic cortex calculates: 72% probability of successful overtake, costs 2% energy, low collision risk. They execute an aggressive late-braking move into Turn 1 next lap. It works. New race leader.
Lap 36: Multiple agents realize they won't finish without pitting. One agent calculates: "Currently P3, pit will drop me to P7, but I'll DNF on lap 42 if I don't pit." They pit, lose positions, but finish P6 instead of not finishing at all.
The final race shows 42 total LLM triggers across 22 agents (average 1.9 per agent over 45 laps). Average FPS stayed at 58.7. Strategic decisions succeeded 88% of the time. The hybrid architecture won through smarter overtake timing and energy management.
How We'll Build It

Core tech stack:
- Mesa or Abmarl for the agent-based simulation
- RLlib with PPO for tactical policies
- Quantized Llama 3 8B (or Gemma 7B) for strategic reasoning
- Ray for parallel simulation
- Plotly Dash for the live leaderboard interface
Why it stays fast:
- Strategic reasoning triggers on heuristics (stuck >3s, energy <20%, etc.)
- LLM calls are asynchronous—simulation never blocks waiting
- Response caching for similar scenarios
- Fallback to pre-computed safe actions if LLM times out
- 4-bit quantization cuts inference time dramatically
Performance targets:
| Scenario | Agents | FPS | LLM Calls/min | Memory |
|---|---|---|---|---|
| Formula E | 22 | 60 | <5 | <1.5 GB |
| Drone racing | 50 | 45 | <12 | <2.1 GB |
| Supply chain | 100 | 30 | <25 | <3.8 GB |
For really large fleets (500+ vehicles in supply chain scenarios), we'll use replay mode for analysis rather than trying to render everything in real-time.
Challenges We Expect
LLM latency: Even quantized models take 180-350ms per call. We're mitigating this through trigger-based activation, caching, and fallbacks, but it's still the main performance bottleneck.
Reward design: Getting agents to balance aggression with safety is tricky. Too aggressive and they crash constantly. Too conservative and racing is boring. We need multi-objective rewards that incentivize smart risk-taking.
Visualization at scale: Rendering 100+ agents with telemetry overlays at 60 FPS needs GPU acceleration and level-of-detail systems for distant agents.
Realistic racing: We need physics-based penalties to prevent exploitative tactics. Track limits, collision penalties, fuel/energy consumption, tire wear—all the stuff that makes real racing strategic.
What We Learned
Strategic thinking doesn't need to be constant
Most of racing is just... racing. You don't need deep strategic reasoning every frame. The interesting decisions happen at specific moments: when someone crashes ahead, when your energy gets critical, when there's an overtake window. A 99/1 split between reflexes and strategy turns out to be exactly right.
Competition isn't cooperation
We spent time reading multi-agent RL papers and realized most of them solve cooperation problems. But racing is adversarial. You're trying to exploit the other guy's weakness. When someone's saving energy, that's your window to attack. The reward structures are completely different from "everyone work together" scenarios.
People trust AI they can understand
Being able to click an agent and see "I'm going for this overtake because 68% success rate and I'm running out of time" makes the whole system feel real instead of random. Explainability isn't just nice to have—it's what makes people believe the intelligence is actually there.
Lightweight doesn't mean dumb
You can build something that's both fast and smart if you're deliberate about when to use which type of intelligence. Trigger-based reasoning with fallbacks gives you strategic depth without killing performance. It's about architecture, not raw compute.
Domain knowledge matters
Formula E isn't just "cars going in circles." Attack mode timing, lift-and-coast energy saving, regenerative braking—these are real strategic elements. Same for MotoGP tire management or drone battery curves. Generic simulation misses all the interesting tactical details that make racing actually strategic.
PS: 100% of the emdashes used in this post are human generated.
Built With
- amazon-web-services
- docker
- github
- javascript
- json
- langraph
- mesa
- mongodb
- python
- react
- rlib
- s3
- yaml
Log in or sign up for Devpost to join the conversation.