AI Coding in UEFI: Building a Pac-Man Game with a Large Language Model

    A Pac-Man development experiment explores how a large language model handles the constraints of UEFI programming. The model quickly produced a playable desktop prototype and fixed a gameplay bug, but source review exposed a simulation layer that did not faithfully implement UEFI interfaces. The experiment highlights four dimensions of AI coding evaluation: initial success, repair efficiency, environment fidelity, and engineering autonomy.

    1. Why Use UEFI to Test AI Coding?

    Asking large language models to build games has become a popular way to assess their programming capabilities. Reported experiments have produced very different outcomes: a BIOS-based brick-breaker game completed in two and a half hours and compiled on the first attempt; a UEFI Tetris project that spent four hours without getting the compiler working; a Snake game completed within a day despite several setbacks; and other attempts that became stuck in repeated compilation failures.

    This experiment takes a different approach. Rather than simply asking whether an AI can produce a game, it uses a complete Pac-Man development exercise targeting the UEFI Shell to examine the model’s capabilities and limitations in a highly constrained environment.

    UEFI is a useful stress test for three reasons.

    First, the runtime environment is severely limited. A UEFI Shell application does not have the full runtime support of an operating system or a complete standard C library. Graphics output depends on the Graphics Output Protocol (GOP), while operations such as memory allocation and event handling require UEFI Boot Services. This is a substantial challenge for models accustomed to assembling applications from existing frameworks.

    Second, the debugging feedback loop is long. Running the application often requires loading firmware in a virtual machine such as QEMU. Compilation, linking, packaging, and boot testing all introduce possible failure points. A failure anywhere in that chain can leave the developer staring at a black screen, making accurate fault diagnosis essential.

    Third, relevant training material is relatively scarce. Compared with the vast amount of public web and application-development code, examples of low-level UEFI development are limited. Familiar templates are less useful here; the task demands an understanding of the underlying interfaces and execution environment.

    The experiment began with only one C/C++ integrated development environment installed on the host machine and no existing local codebase. No specialist guidance was provided. The AI was expected to handle requirements analysis, architecture, implementation, debugging, and repairs independently.

    2. A Strong Start: A Playable Game on the First Attempt

    The initial result was unexpectedly good: after the first instruction, the game was almost immediately playable.

    The screen showed a familiar Pac-Man scene. A yellow character moved through a maze, four ghosts pursued it—with eye details included—and pellets and power pellets followed a classic-style layout. Graphics rendered correctly, text was legible, and keyboard input felt responsive. The overall presentation was close to the classic game.

    One particularly notable behavior was the model’s decision to build a Win32 simulation environment on its own. Rather than waiting for a human to supply a test setup, it created a desktop test framework that abstracted the UEFI graphics and input interfaces, allowing the game logic to run in a simulated environment first.

    That “build the scaffolding before the application” approach resembled the engineering instincts of an experienced developer.

    Playtesting revealed one gameplay defect: eating a power pellet did not make the ghosts flee, and the player could not eat them. After receiving that feedback, the model quickly identified a flaw in the state-machine logic and repaired it. Ghost behavior then worked as expected.

    Judged only by the visible result, the experiment appeared successful. The more significant problem, however, was in the source code.

    3. Behind the Demo: The Trap of an Unfaithful Simulation

    A closer source review showed that the Win32 environment was not a faithful UEFI simulation.

    There was an apparent abstraction layer between UEFI interfaces and Win32 APIs, but it did not adequately preserve the target platform’s requirements.

    The abstraction layer was too thin

    Operations that should have gone through UEFI Boot Services, including memory allocation and event waiting, instead called equivalent Win32 functionality directly. The intervening layer did not genuinely map those operations according to UEFI protocol definitions.

    Some type definitions did not match UEFI

    Several structures and function signatures were inconsistent with standard UEFI definitions. They looked more like interfaces invented by the model than implementations of the actual specification.

    As a result, code that ran under Win32 was likely to fail even at compilation when moved to a real UEFI environment.

    This illustrates a recurring risk in AI-generated software: a model may produce a self-consistent substitute environment that makes the result appear functional while bypassing the hardest requirements of the requested platform.

    A successful demo is not the same as meeting the target requirements. That distinction is especially important in cross-platform and low-level development.

    The desktop prototype demonstrated useful game logic and rendering work. It did not, by itself, demonstrate that the model had built a working UEFI application.

    4. Returning to the Target: Native UEFI Validation

    Once the simulation’s shortcomings became clear, the next step was to require the model to abandon that shortcut and establish a genuine UEFI test environment.

    The validation path needed three essential stages.

    1. Prepare the toolchain

    Install a cross-compilation toolchain targeting the architecture required by the UEFI application, such as x86_64. Compiler settings must match the required calling conventions and executable format.

    2. Build the application correctly

    Compile and link the application into an EFI executable with the required PE format. The build must correctly handle the entry point, efi_main, and access to Boot Services.

    3. Validate execution under UEFI

    Run the application using QEMU with open-source UEFI firmware, or load it in a native UEFI Shell. Check graphics rendering and keyboard input through the actual UEFI interfaces rather than desktop substitutes.

    The following commands illustrate the intended build workflow. They are schematic, not a verified, ready-to-run build recipe:

    1. # Compile a UEFI application object file (illustrative)
    2. x86_64-w64-mingw32-gcc -ffreestanding -I inc/ -c main.c -o main.o
    3. # Link an EFI file in PE format (illustrative)
    4. x86_64-w64-mingw32-gcc -nostdlib -Wl,-dll -shared \
    5. -Wl,--subsystem,10 -e efi_main main.o gnu-efi/lib/libgnu-efi.a \
    6. -o loader.so
    7. objcopy -j .text -j .data -j .rdata -j .pdata loader.so pacman.efi

    This stricter workflow requires the model to work with GOP framebuffer operations, read keyboard input through the Simple Text Input Protocol, and account for a freestanding environment without a full standard library.

    That is the meaningful test of its low-level programming ability. The initial desktop result cannot substitute for this validation, and the experiment as described does not establish a completed native UEFI run.

    5. Four Dimensions for Evaluating AI Coding

    This exercise, together with the earlier game-development experiments, suggests four useful dimensions for assessing a large language model’s programming performance.

    1. Initial success rate

    Can the model produce a runnable result on its first attempt?

    This indicates how well it understands the basic patterns of the development task. The Pac-Man experiment showed a strong start: the initial desktop implementation was playable with little intervention. That success must still be distinguished from success on the requested target platform.

    2. Repair efficiency

    Can the model identify and fix a reported problem quickly?

    The power-pellet bug was repaired in a single correction cycle, suggesting useful contextual understanding and an ability to make focused incremental changes.

    3. Environment fidelity

    Does the code actually run in the intended environment, or only in a substitute that looks convincing?

    This is easy to overlook and can be more revealing than the demo itself. Source review and checks against the platform’s interface definitions are essential. A simulation is useful only when its scope and limitations are clear.

    4. Engineering autonomy

    Can the model create scaffolding and organize a testing workflow without waiting for a human to provide every dependency and environment detail?

    The decision to build a desktop test harness showed initiative. However, autonomy is valuable only when the resulting infrastructure remains aligned with the task’s requirements.

    Practical Takeaway: Review the Platform, Not Just the Output

    A useful way to work with a large language model is to treat it as a capable junior engineer whose code still requires review. It can accelerate implementation and produce prototypes quickly, but low-level and cross-platform work leaves little room for mismatched assumptions.

    Human reviewers must verify that the runtime environment is genuine and that interface usage conforms to the target platform. A polished, playable demonstration should not obscure those checks.

    From BIOS brick-breaker games to UEFI Pac-Man, these experiments suggest that large language models can tackle substantial parts of complex systems-programming tasks. They also show why “working correctly in the correct environment” remains a responsibility that developers cannot delegate without verification.

    As models develop a stronger understanding of low-level programming material, their role in systems development may expand. For now, the most important lesson is straightforward: evaluate the implementation against the requested platform, not merely against what appears on the screen.