Skip to content

Architecture

André Borchert edited this page Aug 22, 2026 · 3 revisions

Architecture

How the AI is designed: a hybrid hierarchy, a shared coalition world model, fog-of-war honesty, an engine-validated tool API, and a headless harness that makes everything testable.

Hybrid hierarchy

Intelligence is deliberately split between a strategic commander and a deterministic tactical engine:

  • Strategic commander (LLM) — a local vision-capable model (Gemma 4 E4B, 4-bit MLX, running on Apple Silicon) is consulted every ~15 seconds. It receives the team's strategic radar: a full-map image (terrain, water, explored territory, currently visible unit dots) plus a compressed team report — per-member composition, cash, provenance-tagged enemy sightings, force split, and an engagement estimate. It replies with strategic intent only: posture, missions (attack, feint, recon, transport, special ops, …), targets, and production direction. It never issues unit-level orders.
  • Tactical executor (deterministic C#) — per-domain controllers (ground, air, naval, transport, special ops) turn the intent into engine orders: build queues, attack waves, retreats and regroup, base defense, feints, transport insertions. All movement, targeting, and pathfinding run at engine speed and are replay-deterministic.
  • Fallback — the LLM is optional. On timeout, invalid output, or no model at all, a deterministic commander keeps playing: posture selection, mission creation, production contracts, waves, defense, and counterattacks all work without a model.

Coalition: one brain, several bots

All allied bots act on the same plan with no message passing:

  • Every allied bot computes the identical coalition blackboard from the shared world state: per-owner force groups, enemy intelligence with confidence decay, per-region threat fields (12 capabilities), region graph, opponent model, and match metrics. Deterministic — no desync, no coordination protocol.
  • The model server caches one plan per consultation round per team, so all bots receive identical orders and opposing teams never share plans.
  • Corps roles specialize the bots (naval / main / escort); a single attack tick synchronizes all bots' waves for time-on-target arrival.

Fog of war & intelligence honesty

  • Exact enemy extraction is gated by current allied visibility in the blackboard, LLM snapshot, radar image, and tool API. Explored terrain alone never exposes a hidden actor's current position.
  • Intelligence carries confidence that decays over time; stale sightings are immutable actor-free snapshots and widen the uncertainty window instead of being reported as fact.
  • The intelligence honesty ladder (observed / last-known / inferred / suspected / unknown) is the model every subsystem is built toward.

Engine-validated tool API

The commander may call read tools (served by the game on a local port) instead of estimating mechanics: intelligence (get_global_summary, inspect_region, inspect_force, inspect_enemy_intelligence, get_recent_events, get_opponent_model, get_uncertainties), analysis (estimate_engagement, compare_force_packages, plan_routes, score_targets, estimate_enemy_response, find_attack_windows, find_special_ops_routes), economy (get_economy_state, get_production_state), and status (get_mission_status, get_force_readiness, get_transport_status, get_route_status). Mutation tools cover production, expansion, missions, force assignment, reserves, reconnaissance, and posture. Every call is validated against the live blackboard; mutations return validated plan patches and never issue actor orders. The complete intent is validated again on the game thread. Intelligence results carry an honesty status (observed / last-known / inferred / suspected) so fact is never silently conflated with inference.

The full C#↔LLM contract (snapshot, intent, mission, threat-field, and tool schemas) is locked in ai/COMMAND_API.md in the repository.

Determinism & testing

  • The headless harness (--simulate) runs complete skirmishes with no renderer: same seed → same outcome; winners, game-overs, and strategic telemetry are reported. Mixed self-play pits the coalition against scripted rush/turtle/naval bots.
  • ai/selfplay.py batches headless matches across seeds and maps, sweeps parameters (e.g. reserve fraction), checks cross-map overfitting, correlates the predicted win ratio with actual outcomes, and uses --bot-type for scripted baseline comparisons.
  • Core subsystems are pure and unit-tested without a game world: map analysis, threat fields, route planning, combat estimation, target scoring, mission phases, transport state machine, opponent model, deception measurement, production contracts, difficulty axes, and the tool API.

Supreme Allied Command AI

Clone this wiki locally