Inspiration

I’ve built games in Unreal Engine for years as a solo indie developer, while exploring AI as an amateur programmer. The idea that stuck was to combine both passions so an AI could act like a live Game Director—pacing tension, offering quests, and spawning encounters—so every playthrough feels authored yet surprising.

What it does

Game Director AI orchestrates gameplay moment‑to‑moment. It:

  • Reads a compact world state (locations, NPCs, flags, tension).
  • Responds with strict JSON tool calls like QuestPatch, SpawnEncounter, SetFlag, WeatherControl, GiveItem.
  • Includes a short reason for transparency and pacing.
  • Balances creative variation with a consistent red thread using story beats and a tension meter.

How I built it

  • Model: Fine‑tuned gpt-oss-20b* for **game orchestration (beats, constraints, tools).
  • Runtime: Runs locally via llama.cpp (GGUF), called from Unreal through a C++ plugin with an async worker.
  • Protocol: Tight system prompt, stop sequences, and sampling constraints to enforce strict JSON.
  • Validation: Lightweight JSON validator/repair in Unreal with a fallback state machine.
  • Authoring: Data assets for tools & beats; a Log Panel shows state → decision JSON → applied changes.

Challenges I ran into

  • Reliable structured output: Ensuring always‑valid JSON required layered controls, repair, and fallback logic.
  • Creativity vs. coherence: Avoiding meandering while keeping surprise—solved with a director contract (world‑state grounding, tension/beat guidance, soft lore constraints, hard tool limits).
  • Local performance & stability: CUDA builds, quant choices, context sizing, and keeping the game thread responsive while streaming tokens.
  • Tool safety: Acting only on present NPCs/regions/quests and no invented items or lore.

Accomplishments that I am proud of

  • A live, local Game Director that issues deterministic tool JSON the game can execute safely.
  • Sessions that feel authored yet replayable with clear reasons, tight actions, and evolving tension.
  • Clean Unreal integration (llama.cpp bridge, async generation, data‑driven tools) that drops into existing projects.
  • Developer‑friendly observability with a Log Panel and traces.

What I learned

  • For orchestration, constraints beat cleverness: prompt + tools + state + guardrails matter more than raw model size.
  • Output discipline (schema, stops, validation) is as critical as model quality.
  • A few small, reliable decisions per tick outperform one big flaky decision in a live loop.
  • Keeping it local improves iteration speed, privacy, and cost predictability.

What’s next for Game Director AI

  • Authoring UX: Visual beat graphs, tension curves, and tool palettes.
  • Further reduce size of GGUF file
  • Introduce Grammar to reduce reasoning in response and reduce time to tool usage.
  • Encounter & quest templates: Reusable patterns parameterized from world state.
  • Playtesting metrics: Auto‑telemetry on tension, variety, and coherence to tune models and rules.
  • Co‑op & multi‑agent: Coordinating multiple directors (combat, economy, narrative) via shared state contracts.
  • Packaging: Polished Unreal plugin with docs, sample levels, and drop‑in data assets.

Built With

Share this project:

Updates