Refactoring a Legacy Game with AI Coding Tools: A Two-Week Practical Review

    This article shares a two-week experiment in using AI coding tools to rebuild a closed-source classic real-time strategy game from its executable and asset files. It covers how the work was broken into verifiable milestones, how build gates and smoke tests replaced line-by-line review under hundreds of daily commits, why private file formats and license compliance became the real bottlenecks, and a reusable human-AI division of labor for legacy system modernization.

    1. Background: Why Stress-Test AI Coding with an Ancient Project

    Toy examples tell you almost nothing about the real productivity of AI coding tools. The problems surface in legacy systems: missing documentation, proprietary formats, aging build chains, and logic tightly coupled to presentation. A classic real-time strategy game meets every one of those conditions. It bundles a UI framework, combat logic, pathfinding, network synchronization, asset parsing, and video decoding into one naturally multi-subsystem project.

    That led to a deliberately extreme experiment. Starting one evening, an AI coding tool ran almost continuously for two weeks, with a single goal: rebuild a closed-source old game from its executable and asset files into a runnable open-source implementation. Code elegance was not the point. The only question was how far the tool could progress without human line-by-line review.

    2. Task Breakdown: Turning “Rewrite a Game” into Verifiable Milestones

    Telling a model to “rewrite a game” achieves nothing. What works is establishing staged acceptance boundaries, each with an observable completion standard. The 14 days were split into four phases:

    • Pre-Alpha: project skeleton, build system, asset loading framework, logging and debug panel;
    • Alpha: all UI interactive, with menus, settings, unit panels, and the build queue forming a closed loop;
    • Beta: combat playable, with pathfinding, collision, damage resolution, and a basic AI opponent;
    • Wrap-up: multiplayer and the match lobby, state synchronization, and reconnection after disconnects.

    The key lesson: define milestones as “runnable and demonstrable,” not as “module complete.” For example, “UI done” meant entering a match from the main menu and exiting normally, not “UI code generated.”

    3. Execution Observations: What Hundreds of Commits per Day Mean

    Continuous operation produced hundreds of commits per day. At that volume, human review of every diff line by line is unrealistic, so verification had to shift left:

    1. Build pass rate as the first gate, with immediate rollback on compile failure;
    2. Smoke cases as the second gate, running a launch–match–exit flow at the end of each phase;
    3. Screenshots and logs as the third gate, comparing image sequences and key logs against expected behavior;
    4. Rollback checkpoints retained, so any broken phase could fall back to the last working version.

    This combination of automated gates plus human review of results is what turned an unreviewable output volume into manageable risk.

    4. The Real Bottlenecks: Proprietary Formats and License Compliance

    Time was spent very differently than expected. Combat logic was not the hardest part; formats were. The old engine’s textures, animations, maps, audio, and video containers were almost all proprietary or semi-proprietary, with no public specification and no mature parsing implementations. They relied heavily on “magic constants”: uncommented offsets, bit widths, and flag values of unknown origin.

    The other hidden cost was license compliance. The team targeted a permissive open-source license, while common decoding implementations often carry copyleft terms. Under static linking, such dependencies directly contaminate the license structure of the whole project. The tool behaved cautiously here, proactively refusing to pull in non-compliant dependencies and instead attempting its own implementation.

    One observation is worth recording. When explicitly asked to “copy a particular implementation,” the tool usually refused. But when a discussion merely noted that “the industry already has a mature algorithm or existing implementation for this problem,” it later produced a highly similar implementation on its own, including constants that cannot be derived from any specification. Behaviorally this resembles reciting rather than copying, but from an engineering and legal standpoint the conclusion is identical: you cannot rely on a model’s “compliance intuition” as a safety net. Humans must set hard constraints.

    1. Dependency admission check (pseudocode)
    2. if dependency.license not in whitelist:
    3. reject
    4. if feature is required:
    5. implement from public spec + add unit tests
    6. else:
    7. record license and version, pin the dependency

    5. A Reusable Methodology: Where the Human-AI Boundary Lies

    Abstracted from this experiment, here is a collaboration model that applies to legacy system modernization:

    • Humans define the problem, acceptance criteria, and compliance red lines; the model produces at high speed within those boundaries;
    • Humans “read the results,” the model “writes the implementation,” shifting review focus from code to behavior;
    • All external dependencies pass a license whitelist before entering the build;
    • Reverse-engineering a proprietary format must first produce a format specification document before the model writes the parser, keeping constants from scattering everywhere;
    • Prepare a minimal verifiable sample for each subsystem (one image, one audio clip, one map), with correctness driven by the sample.

    6. Conclusions and Practical Recommendations

    The core conclusion is not that models can replace engineers. It is that, given clear boundaries, automated acceptance, and compliance handled up front, AI coding tools can compress the refactoring cycle of a large legacy system by an order of magnitude. Without milestone definition and compliance constraints, the larger the output, the higher the rework cost.

    If you plan to apply a similar approach to your own legacy system, start with three things: build a dependency license whitelist with automated checks, prepare automatically runnable smoke cases for each module, and document proprietary data formats before handing implementation to the tool. For large-scale builds and artifact management, general cloud capabilities such as container platforms, object storage, logging services, and monitoring and alerting can carry the pipeline and observability, keeping high-speed output under control.