Skip to content
shiva.wm
--:--

screeps-ai

an autonomous colony AI under a hard cpu budget

activeautonomous game AI2025 — present

A fully autonomous Screeps AI — roughly 76,000 lines of TypeScript across 138 files — that runs a colony from bootstrap economy to multi-room empire with no human at the wheel. Its most substantial component is automated base defense solved as a graph problem: a 2,657-line weighted minimum-cut solver (a Dinic max-flow adaptation) that node-splits every tile into in/out nodes, runs max-flow from the room exits to the protected core, and prunes the result into a compact, gap-free rampart perimeter — paired with a two-pass distance transform that auto-places the base in the largest open area.

The system is structured as a pipeline of 27 managers and 26 enum-dispatched creep roles across 10 room-planning modules, driving static and remote mining, multi-room expansion, link logistics, lab boost chains, and an inter-room terminal network with a distance-based transfer-cost model.

Because the game enforces a hard per-tick CPU budget, performance is a first-class concern: a profiler-instrumented main loop, bucket-aware throttling that backs off only when the colony is CPU-negative, and a compressed, TTL-evicted path cache keep every tick inside budget. A 22-file live operator console with namespaced commands and a toggleable visualization layer makes the running colony fully inspectable; it is compiled with Rollup, fully typed against @types/screeps and linted with typescript-eslint.

stack
TypeScriptRolluprollup-plugin-screepsDinic max-flow / min-cutdistance transformlodash@types/screepstypescript-eslintNode.js