🧩 Sub-Engine: Games as Data, Not Classes
Sub-Engine started from a stubborn question: what does a game engine look like if its primary author is an AI coding agent? The answer is a 2D engine with no class hierarchy to memorise — entities are integers, components are flat JSON, and systems are pure functions of the form (registry, dt) => registry. Everything an agent (or a person) needs to generate a working game is data and a small, verifiable vocabulary.
What it is
@sub-engine/core— a headless engine with zero browser dependencies: a registry, runtime schema validation, built-in systems, a fixed-timestep game loop, and navigation.@sub-engine/pixi— an optional rendering bridge over PixiJS: responsive containers, sprite loading, tilemaps and a debug overlay.create-sub-engine— a CLI that scaffolds a new game with the contract-first structure the reference titles use.- Fifteen reference games — tower defence, RTS, RPG and management sims — that double as executable documentation for every feature.
Design decisions with scars behind them
The engine's rulebook reads like a set of post-mortems because it is one. A swarm game leaked roughly 180,000 GPU objects in thirty seconds because PixiJS's removeChild does not free GPU memory; the fix — mandatory destroy({ children: true }) — is now a constitution article, not a note in a changelog. A movement bug that made units travel "125 tiles per second" on a 30-tile map traced back to a missing timestep scale, so the engine now states its velocity convention explicitly: units per 16ms tick, converted from a familiar per-second value.
The architecture keeps two registry implementations behind one interface: a straightforward MapRegistry and a ColumnarRegistry built on typed arrays for bulk numeric work. Schema validation runs on every write, which is what turns "the agent typo'd a component field" from a silent bug into an immediate error. Simulation runs headless in Node, so game logic is testable without a browser.
Tech stack
| Technology | Role |
|---|---|
| TypeScript | Strict, ESM-first engine code |
| PixiJS | Rendering bridge (@sub-engine/pixi) |
| Vite | Reference-game dev server and builds |
| Vitest | 201 tests across core and renderer |
| npm | Published packages and CLI scaffolding |
The result
Sub-Engine is public and installable — @sub-engine/core, @sub-engine/pixi and create-sub-engine are on npm under the MIT licence, with the source at github.com/Type-3-studio/sub-engine. It is research that escaped the lab: an experiment in what makes a codebase legible to machines, shipped as a tool humans can use today.