LancerLab

Teaching a Local 24B LLM to Play RimWorld on an RTX 3090: Sockets, Bugs, and Macro Control

⏱️ ~4 min read

Can a local LLM play a hardcore colony simulator like RimWorld 1.6 in real time—with zero cloud APIs, a live stream HUD, and sharing a single RTX 3090 (24 GB VRAM) with the game itself? In one day of intense iteration, RimWorldLancAIMod grew to 6,589 lines of C# (21 files), survived 10 recorded runs and 15 live hot-patches without restarting the game, reached 7 consecutive in-game days, and led to a decisive architectural pivot.

1. C# Reflexes (1s)ReflexSafetySystem • zero LLM2. Inspector & SocketsBaseArchitect • 22 sockets3. RTX 3090 (24B LLM)LM Studio • ~15.8 GB VRAM4. Executor (29 ops)ActionExecutor • BlueprintsLive Telemetry (4s)live_briefing.txt • 23×23 ASCIIZero-Restart Hot-ReloadAssembly.Load(byte[]) • 15 patches
Three-Tier RimWorldLancAIMod Architecture on a Single RTX 3090 (24 GB VRAM)

1. Why 24B Instead of 32B on 24 GB VRAM

We ran mistral-small-24b-instruct-2501 in LM Studio (:1234/v1). Unlike a 32B model, 24B takes ~14.3 GB VRAM (+ ~1.5 GB KV cache), leaving enough headroom on the same GPU for RimWorld (~2.5 GB) and stream capture while keeping latency snappy. Even the game’s entity catalog Data/defs_catalog.json (27,287 bytes) was extracted by the local model itself via a dedicated rimworld-def-extractor skill.

2. Why Raw JSON Failed & Moving to 22 Semantic Sockets

Asking the LLM for raw (x, z) wall and crop coordinates predictably produced geometry chaos. The fix was strict separation of concerns:

  • Tier 1 — C# Reflexes (1s loop, zero LLM): ReflexSafetySystem.cs handles immediate combat threats, fires, and downed pawns.
  • Tier 2 — Inspector & Geometry: StateSerializer.cs builds a compact tactical briefing, BaseArchitect.cs (576 lines) and ColonyLogisticsAndRooms.cs (539 lines) compute room layouts and wind corridors, and SocketResolver.cs maps decisions to 29 primitives in ActionExecutor.cs.
  • Tier 3 — Local 24B Strategist: reads the briefing and fills 22 high-level semantic sockets (plan_room, setup_freezer, auto_wire_power, create_farm_on_best_soil, defend_colony, bury_corpses, etc.).

On screen, StreamOverlay.cs renders a live HUD with Goal / Analysis / Thought, a verified TaskChainManager queue, and a 3-tab debug inspector.

3. Real AI Failure Modes Caught in Live Runs

  • 364 trees queued, 0 chopped: work-role assignment enabled Growing but missed PlantCutting, so wood stayed at zero while the bot kept marking the forest.
  • 13 campfires & 11 beds for 3 colonists: fast-build testing without per-colonist caps turned rooms into furniture warehouses.
  • Steel = 3195 while reporting Steel = 0: RimWorld’s map.resourceCounter only counts items inside stockpile zones. Once a 3×3 stockpile filled with wood and meals, mined steel on the ground was invisible. Switched to map.listerThings.ThingsOfDef.
  • A -5°C freezer venting into the bedroom & walled-in pawns: extending a room sealed off doors and roofed over potato crops and solar panels.
  • Dual roof grids: in RimWorld’s engine, BuildRoof and NoRoof are independent grids—setting BuildRoof does not clear an earlier NoRoof flag.
  • Collection was modified crash: un-drafting pawns inside a FreeColonists foreach loop threw an exception and froze IsThinking.

4. The Macro-Control Pivot: Play Like a Human, Not a Macro

Across 10 logged runs (LancAI_Reports), the colony progressed from a Day 2 wipe (Wood=2, 0W) to surviving Day 7 (Wood=2146, Meals=455 / ~24–28 days of food, 1094–1779W net power, 1200Wd stored, separate bedrooms).

At that point, the real lesson clicked: instant GenSpawn.Spawn shortcuts and household micromanagement fight the game’s own AI. In the final build of the day, instant spawning and chore micromanagement were removed in favor of blueprints (PlaceBlueprintForBuild), Deconstruct orders, native WorkGiver priorities, and StoragePriority filters—reserving Draft and rallyCenter grouping strictly for combat.

More from the Lab
← ESP32 + Quansheng UV-K5: Wireless Wi-Fi Programmer and Reception DebuggingZero-Restart C# Hot-Reload in Unity/Mono: Shipping 15 Live Patches Inside a Running Game →

Комментарии

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *