Retro: An AI Agent Autonomously Developing a UEFI Graphics Game

    This article reviews an experiment in which an AI coding agent autonomously built a graphical Breakout game that runs in the UEFI firmware Shell, with Chinese text rendering included. It covers the strict constraints of the experiment, why Breakout was chosen as the verification target, the runtime differences of the firmware environment, a three-stage rendering pipeline, the four challenges of Chinese font display, rule design for AI autonomy, and model sizing and cost trade-offs. The conclusions are reusable for embedded GUIs, bootloader interaction layers, and any development in constrained environments without a standard library.

    1. Experiment Goals and Hard Constraints: Breaking “Impossible” into Acceptance Criteria

    The rules of this experiment were deliberately strict. The development machine ran on a general-purpose desktop OS with only a basic IDE containing a compiler and debugger—no third-party libraries, no script runtimes, no package managers, and zero pre-existing local code. The developer wrote no code and provided no implementation-level guidance; the AI coding tool did all the work autonomously.

    The goal was equally challenging: produce a graphical Breakout game that runs in the firmware Shell environment with Chinese text support. In practical terms, this meant copying the executable to a USB drive, plugging it into a computer, entering the firmware Shell, and running it directly.

    The value of this kind of experiment lies not in the artifact itself, but in pushing the boundary of “AI autonomous development” to its limit—when there is no operating system to fall back on, can the model still maintain engineering discipline?

    2. Why Breakout as the Verification Vehicle

    Breakout is a long-standing verification project because it has a clear structure and complete logic, while covering five core areas simultaneously: graphics rendering, user input, collision detection, frame-rate control, and state machines. The rules are known, the outcome is verifiable, and completion can be objectively assessed. The same verification had previously been done on browser and mobile graphics stacks. Switching to the firmware environment significantly raised the complexity, because the entire supporting system is missing.

    3. Runtime Differences in the Firmware Environment: The Source of All Trouble

    Compared with conventional application development, the firmware environment differs in six key ways:

    • No standard runtime library: Basic functions like memory copy, zero-fill, and string comparison must be implemented from scratch, or linking fails outright.
    • Constrained memory lifecycle: Dynamic allocation depends on the boot-services phase; once that phase exits, the memory pool becomes invalid. You cannot assume “new anything, anytime.”
    • Manual display driving: You must query available resolutions via the graphics output protocol, set the display mode, and then write pixels into the framebuffer yourself.
    • Polled input: Keyboard and mouse are sampled through protocols; you handle scan-code-to-character mapping and debouncing on your own.
    • Self-built timing: The main loop is constructed from events and timers to achieve a fixed time step.
    • Special artifact format: The output must be linked as an executable image with a firmware subsystem identifier, not an ordinary desktop program.

    A schematic main-loop skeleton (pseudocode, structure only):

    1. while (running) {
    2. sample_input(&keys); // Poll keyboard/mouse protocols
    3. update(&state, FIXED_DT); // Advance physics at a fixed step
    4. render(&state); // Clear screen + swap double buffers
    5. wait_event(16); // Control frame rate via timer
    6. }

    4. The Rendering Pipeline: A Three-Stage Iteration from “Working” to “Good”

    Stage one, functionality. Build the minimal closed loop: rectangle fills, sprite blitting, an off-screen buffer, and full-frame swapping. The only goal at this stage is “it runs and the logic is correct”—visual polish is deliberately ignored.

    Stage two, visual polish. Introduce a limited palette, background gradients, ball trails, and UI regions so the screen gains readable layers. The benefit is not just aesthetics—visual layering dramatically speeds up locating collision and state bugs.

    Stage three, display hardening. Handle real-world hardware diversity: probe available modes at startup and fall back step-by-step to lower resolutions on failure; add bounds clipping to all drawing operations to prevent out-of-range framebuffer writes that cause screen corruption or crashes.

    5. Tackling Chinese Text Display: Four Hurdles

    1. Source encoding and literals: Standardize source file encoding to avoid unexpected character conversion at compile time.
    2. Wide-character paths: Use wide string literals and fixed-length wide buffers to eliminate narrow-character truncation.
    3. Glyph sourcing: There are no system fonts in the firmware environment, so you must bundle a bitmap font, build a codepoint-to-glyph-index mapping table, and draw each glyph bit by bit at 16×16 or 12×12 dot-matrix sizes.
    4. Layout rules: CJK characters are full-width, so the cursor advances at 2× the Latin width, with baseline and line-height alignment; missing glyphs render as placeholder boxes rather than garbled characters.

    6. Designing Rules That Let the AI Stay Autonomous

    Constraints should not be minimal—they should be explicit and verifiable:

    • Give acceptance criteria, not implementation steps: State “after entering the Shell, arrow keys are controllable and the Chinese title displays,” rather than prescribing which functions to call.
    • Single source of truth: Write all constraints into the project README to prevent constraint drift over long sessions.
    • Keep a runnable intermediate state: Every change must still compile and boot, preventing errors from accumulating beyond diagnosability.
    • Feed failures back: Return compile errors and runtime symptoms verbatim, letting the model do its own root-cause analysis.
    • Hard prohibitions: No external dependencies; no assumptions about uninstalled runtimes.

    7. Model Sizing and Cost Trade-offs

    Models of different sizes differ noticeably in response speed, long-context consistency, and complex instruction following. Costs accumulate quickly in high-intensity long sessions, so a more pragmatic approach is task layering: hand boilerplate code, bulk searching, and formatting to a lightweight model; reserve architecture decisions and tough debugging for a high-end model; and use rolling summaries to compress context and avoid re-feeding. On platforms such as Baidu AI Cloud, this kind of batch evaluation and artifact archiving can run on general-purpose capabilities—container platform, object storage, logging service, and monitoring/alerting—decoupled from the specific model choice.

    8. Reusable Conclusions

    • In an environment with no system support, build the “runtime foundation” first—then talk about features.
    • Visual polish is not decoration; it is a debugging-efficiency tool.
    • Internationalization must be designed in at the architecture stage; retrofitting is extremely expensive.
    • The success rate of autonomous AI development depends on constraint clarity and a closed verification loop, not on any single model capability.

    This methodology transfers directly to embedded GUIs, bootloader interaction layers, and any development in constrained environments without a standard library.