Building a Classic Game in the UEFI Shell with AI Coding: A Benchmark for LLMs

    This article uses the task of building a classic top-down tank game in the UEFI Shell to evaluate the coding capabilities of several LLMs. It outlines the technical constraints of the firmware environment, identifies build environment adaptation as the key differentiator, and shows that invalid retry loops—not code volume—drive the cost of AI coding. It also shares practical context engineering practices and budget guardrails for running reproducible LLM evaluations.

    1. Why the UEFI Shell Is a Tough Test for AI Coding

    When evaluating an LLM’s coding ability, task design matters more than model selection. An ideal benchmark task needs to meet three conditions at once: an unfamiliar environment, a long dependency chain, and verifiable results. Developing a graphical application at the firmware layer satisfies all three—there is no conventional operating system to lean on, graphics must be obtained through the graphics output protocol provided by the firmware, and the build depends on a full cross-compilation setup.

    I used the same task to test several LLMs one after another, asking each to implement a classic top-down tank game: a fixed map, player tank movement and shooting, enemy tanks spawning in waves, a base to protect, destructible brick walls, several power-ups, and a win condition that requires surviving all waves, with no sound. I emphasize “the same task” because a fair horizontal comparison is only possible when the input is identical.

    One trade-off is worth noting: this article focuses only on domestic Chinese models. The reason is practical—the more people use a model, the more feedback it gets, the faster it iterates, and the more likely its cost is to fall with scale. This is a choice, not a technical judgment.

    2. Technical Constraints of the Target Environment

    The task runs in a virtual machine firmware environment. The key points of the graphics stack are:

    • Obtain the pixel buffer through the firmware’s graphics output protocol, with a fixed resolution of 640×480 in BGRA format;
    • Use pure software rendering, maintaining the frame buffer and dirty rectangles yourself, targeting a stable 30 FPS;
    • Rely on keyboard/key events provided by the firmware for input, requiring your own event polling and debouncing;
    • Integrate the project into an EDK2-style build system, where a .dsc file describes modules and a .fdf file describes the firmware image layout.

    The illustrative initialization logic is roughly as follows (conceptual only, not a specific implementation):

    1. // Pseudocode: get the graphics output protocol and switch to the target mode
    2. EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
    3. status = g_boot->LocateProtocol(&GopGuid, NULL, (VOID**)&gop);
    4. if (EFI_ERROR(status)) return status;
    5. status = gop->SetMode(gop, 0); // select the 640x480 mode
    6. UINT32 w = gop->Mode->Info->HorizontalResolution;
    7. UINT32 h = gop->Mode->Info->VerticalResolution;
    8. UINT32 stride = gop->Mode->Info->PixelsPerScanLine;

    The difficulty is not in these calls themselves, but in whether the model knows what to check after a failure.

    3. The First Pitfall: Build Environment Adaptation Is the Real Dividing Line

    By the standard workflow, the first step is to have the model generate a Chinese project description file that turns the requirements into context. This step takes very little time and costs almost nothing, and all six models passed it.

    The real dividing line is the second step: put the code into the emulator project directory, build it with a local compiler, and run it in the firmware emulator. Only two models made it through; the rest all got stuck. The symptoms were highly consistent:

    1. Repeatedly editing the module description file, adding or removing library class mappings;
    2. Adjusting firmware volumes and file paths in the image layout file, causing modules not to be found;
    3. Trying to “fix” compilation errors by installing dependencies, when the actual error was unresolved symbols;
    4. Once error messages were truncated, the model started guessing instead of reading the full log.

    A general rule can be abstracted here: when environment configuration fails, the cost of a model’s invalid loops is far higher than that of a business code error. A business logic mistake is fixed in a few lines; a build system incompatibility can burn tens of thousands of tokens with the model still spinning in place. So I set a hard stop-loss line: if the same type of build error appears three times in a row, switch the runtime approach immediately instead of continuing to invest.

    After switching approaches, I explicitly required using a virtual machine with a standard firmware image for debugging and running. The payoff was immediate: the model stopped wrestling with project configuration and refocused on rendering and the game loop.

    4. Context Engineering: Four Things That Keep the Model on Track

    • Lock down requirements before coding: write the gameplay, resolution, pixel format, and frame rate target into the project description file to avoid repeated confirmation later.
    • Provide enough environment facts: compiler version, build script entry point, target architecture, and how to view logs—missing any one of them costs an extra round of trial and error.
    • Force log reading: require the model to paste the first several lines of the full error before changing code, and forbid modifying configuration based on guesses.
    • Verify in small steps: first draw a single pixel or a static background image to confirm the graphics pipeline works, then layer on sprites, collision, and wave logic.

    Following this order, the final output included eight maps, four types of enemy tanks, five power-ups, and a simple particle system, with the frame rate holding near the target and the full code ready to pull and run.

    5. Cost and Efficiency: Set a Budget Red Line for AI Coding

    In this test, wrestling with the build environment accounted for more than half of the actual spend, while producing zero effective code. This suggests that the cost structure of AI coding differs from traditional development: cost is driven mainly by the number of invalid loops, not by the amount of code.

    Three actionable practices:

    1. Set a budget cap per phase; when it is exceeded, switch strategy rather than adding more investment;
    2. Use verifiable intermediate artifacts as milestones, such as “background rendered successfully” or “a single tank can move”;
    3. For environment-related problems that fail repeatedly, switch to a simpler runtime path directly, trading time for certainty.

    6. Conclusion

    Under this firmware-layer benchmark task, the models separate into clear tiers: requirement understanding and code generation are now generally usable, while the gap concentrates on environment adaptation and self-correction. Whoever can read the full error and stop invalid attempts in time can push the task to the finish line. For developers, rather than chasing a single leaderboard score, it is better to make the evaluation method reproducible: the same task, the same environment, the same stop-loss rules, and the same cost accounting. This method also applies to selecting AI coding tools in cloud development scenarios such as container platforms, logging services, and monitoring and alerting.