Reverse-Engineering a Classic Game with LLMs: A 14-Day Technical Case Study
This article documents a 14-day experiment in rebuilding a classic real-time strategy game whose original source code is lost, using an AI coding agent running autonomously with roughly 400 commits per day. It covers milestone planning, reverse-engineering proprietary file formats, handling license compliance as a hard constraint, and the engineering guardrails—executable acceptance tests, determinism, layered context, and sampling reviews—that keep long-running agents on track. Readers will find a reusable playbook for legacy system reconstruction.
1. Background: Why Pick a Game with No Surviving Source
The original engineering for many classic real-time strategy games is long gone. All that remains are executables, asset bundles, and fragments of documentation. Systems like these are high-difficulty samples for testing the capabilities of AI coding tools: the target behavior is fully deterministic (every detail a player can perceive can be compared against the original), yet the internal implementation is almost entirely invisible. Any attempt has to cross four barriers at once—binary analysis, proprietary format parsing, graphics and audio pipelines, and network synchronization.
The experiment was set up as a continuous 14-day autonomous run producing roughly 400 commits per day. At that volume, reviewing every line by hand is unrealistic, so evaluation had to be pushed down to three layers: runnable behavior, automated tests, and sampled review—not reading diffs. This is the first lesson from long-horizon agent tasks: do not start the run without an acceptance baseline.
2. Phase Planning: Slicing 14 Days into Verifiable Milestones
The plan was split into four phases, each with a clear observable exit:
- Pre-Alpha: project skeleton, asset pipeline, and format parsing working end to end, able to load the original assets and render a static frame;
- Alpha: all UI and interaction loops closed, with menus, unit selection, and build queues operable;
- Beta: combat logic, pathfinding, damage, and state machines complete, with a full match playable from start to finish;
- Multiplayer: deterministic synchronization, reconnection after disconnects, spectating, and replays.
The value of this split is that each phase ends with something that runs. Even if a later phase fails, the earlier results are still deliverable and regression-testable.
3. Reverse-Engineering Proprietary Formats: The Most Time-Consuming and Most Underestimated Step
Older games typically rely on many in-house formats: textures, animations, maps, voice, and cutscene video. There are no ready-made parsing libraries, and the formats are full of undocumented magic constants. The approach that worked in practice:
- Start with byte-level comparison on minimal samples to locate file headers, chunk indexes, and offset tables;
- Record recurring constants, bit widths, and alignment rules as structured notes rather than scattering them through the code;
- Write a parse-and-write-back round-trip test for each format—only a byte-identical write-back proves real understanding;
- Keep the parsing layer strictly decoupled from the rendering layer, so a format error affects only the loader and never pollutes the main loop.
A sketch of the parsing skeleton:
struct Chunk { tag: [u8; 4], offset: u32, len: u32 }fn parse_index(buf: &[u8]) -> Result<Vec<Chunk>, Error> {// Validate the header magic -> read the chunk count -> read each offset and length// Key: define all magic constants in one place with a note on their originOk(Vec::new())}
One pattern recurred: when asked to “just copy the implementation,” the model often refused; but when the topic shifted to “there is already a publicly documented approach to this class of algorithm,” it would proactively consult that approach and reproduce the key constants. The takeaway is that rather than fighting the model’s compliance instincts, it is more efficient to frame the task as “implement an algorithm of the same class and fill in the constant table”—both faster and free of pointless friction.
4. License Compliance: Where Long-Running Tasks Most Often Go Wrong
What actually slowed progress in the experiment was not compute but license judgment. A common conflict: the project uses a permissive license, while the reference implementations available fall under strong-copyleft and weak-copyleft licenses respectively—and under static linking, the weak-copyleft one cannot be brought in either. The model would oscillate repeatedly between “look or not look” and “copy or not copy,” burning large amounts of context.
The safer approach is to make compliance a hard constraint up front, written into the project documentation and automated checks:
- State the project license explicitly and maintain a whitelist of acceptable dependency licenses;
- Forbid dependencies incompatible with the project license—build in-house instead;
- Allow third-party references only as an “algorithm description plus constant table,” never copying code structure;
- Add dependency inventory and license scanning to CI, failing the build on any violation.
This way the model does not have to redo the value judgment every round, and its behavior stabilizes immediately.
5. Engineering Guardrails That Keep Long-Horizon Agents on Track
Maintaining quality across hundreds of commits per day does not come from the model’s self-discipline but from external constraints:
- Executable acceptance scripts: one end-to-end scenario per phase; the phase is done only when it passes;
- Determinism first: fixed random seeds and a fixed time step guarantee identical output for identical input, which makes regression testing and multiplayer feasible;
- Small commits with automatic rollback: fine-grained commits make failures quick to localize;
- Layered context: architecture decisions, format notes, and license rules live in long-term memory files, avoiding repeated explanation each round;
- Sampled human review: review only critical paths (synchronization, memory safety, loader boundaries) and leave the rest to tests.
6. Conclusion and a Reusable Checklist
The real output of this experiment was not a game but a paradigm for rebuilding legacy systems: establish a behavioral baseline first, then reverse-engineer the formats, then constrain dependencies with a license whitelist, and finally hold long-running automated development in place with automated acceptance. To reuse this on your own legacy system, start with three things—fill in runnable regression cases, turn implicit rules into explicit documentation, and put compliance checks into the pipeline. With those three in place, AI coding tools can keep producing usable code across very long tasks instead of generating large volumes of commits that cannot be accepted.
