Evaluating Large Language Models on Interactive Game Generation: A Layered Framework and Repair Strategies

    This article examines how to evaluate large language models' ability to generate interactive games that are not just code but fully runnable systems. It introduces a layered evaluation framework covering visual consistency, interaction loops, state machines, multi-round repair, observability, and regression testing; analyzes typical failure modes such as disappearing entities, unresponsive buttons, and coordinate drift; and proposes a practical baseline-repair-smoke-regression workflow with a state-machine code example. Readers will learn why single-shot code generation is insufficient and how to systematically assess real-world delivery capability.

    Evaluating Large Language Models on Interactive Game Generation: A Layered Framework and Repair Strategies

    1. Background: From “Generating Code” to “Generating Runnable Interactive Systems”

    Discussions about code generation benchmarks often stop at whether the model produced complete code or whether the page loads. For interactive games, simulations, and training scenarios, however, what determines real usability is not the amount of code generated in one shot, but whether the system can reliably enter a running state, whether interaction chains are fully closed-loop, whether state transitions remain consistent, and whether existing functionality survives multiple rounds of defect repair.

    Consider a basketball mini-game. Even a seemingly simple scene includes several subsystems: court and hoop drawing, player entities, movement logic, shooting/passing/stealing actions, score and commentary, and an auto-demo mode. If evaluation only checks “whether the net was drawn,” it misses the more critical questions: Are the players visible? Are the buttons clickable? Does the game start? Are auto-demo and player input mutually exclusive? Do multiple repair rounds introduce new defects? A more appropriate evaluation target is therefore the “runnable interactive system” rather than the “code snippet,” and the evaluation method should shift from single-point visual checks to layered verification.

    2. Core Evaluation Dimensions

    2.1 Visual and Geometric Consistency

    The visual layer must verify not only that elements exist, but also that coordinate spaces, layering, and geometric proportions are consistent. The hoop, net, and court markings should live in the same coordinate system and retain their relative positions after scaling, centering, and window resizing. Misaligned markings or a net offset from the hoop usually indicate hardcoded coordinates, mixed coordinate systems, or missing layout recalculation when the container size changes.

    2.2 Interaction Chain Completeness

    Interaction testing should cover four stages: discoverable, triggerable, responsive, and recoverable. A visible button is not necessarily clickable; a clickable button does not mean its event is correctly bound; after an event fires, you must check whether state changes, animations play, and the score updates. Actions such as shooting, passing, and stealing should each be tested for click, touch, and keyboard mappings, including disabled states, cooldowns, and protection against duplicate clicks.

    2.3 State Machine and Lifecycle

    A mini-game is essentially a state machine. States such as ready, playing, paused, ended, and auto-demo need explicit transition conditions. When characters cannot move or the game cannot start, the cause is often not rendering but an initialization state that never transitioned, a clock that never started, or input blocked by a state gate. If auto-demo shares the same state as player input without isolation, input conflicts are likely.

    2.4 Controllability of Multi-Round Repair

    The ability to survive multiple repair rounds is what separates “can generate” from “can deliver.” Each repair round should record the scope of changes, regression pass rate, and preservation of existing functionality. If fixing one button makes characters disappear, the modification lacked impact analysis; if the system gets less runnable with each fix, there is no regression verification or version comparison.

    2.5 Observability and Regression

    Observability includes runtime logs, state snapshots, error capture, and key-event instrumentation. Without these, multi-round repair relies on visual impression and cannot answer “why did the character disappear” or “why is the button dead.” Regression requires that every change automatically executes smoke tests covering at least: page load, game start, character movement, main buttons, auto-demo, and the end flow.

    3. Technical Attribution of Typical Failure Modes

    In a comparative test, two typical patterns were observed. One solution drew the net correctly, but after several repair rounds all characters disappeared, the shoot/pass/steal buttons became unclickable, and the game could not even start. Another solution moved characters normally and offered an auto-demo mode, but the hoop and markings were offset and the character moved slightly too fast. Abstracted, these failures can be attributed as follows.

    First, entity lifecycle coupled with the render list. Disappearing characters usually do not mean “the character does not exist”; rather, the entity was removed from the render list, its coordinates became invalid, it was occluded by another layer, or its visibility flag was wrongly cleared. Patch-style fixes that directly clear or rebuild the list can easily delete other entities.

    Second, incorrect event binding timing. Dead buttons often result from binding the event before the element is created, selector mismatches, an overlay intercepting clicks, the button being disabled, or the handler being aborted by an exception. If subsequent repairs only change styles but not bindings, the problem persists.

    Third, incomplete initialization state transition. If the game cannot start or characters cannot move, the start button may not trigger a state transition, or the main loop may not be running. The page “looks complete,” but there is no clock driving it at runtime.

    Fourth, inconsistent coordinate spaces and time steps. Marking offsets usually stem from coordinate systems, container scaling, or pixel-ratio handling. Overly fast movement is typically caused by a missing frame-rate-independent time step. Movement should be driven by fixed timesteps or delta time to avoid speed drift at different refresh rates.

    Fifth, auto-demo and player input not isolated. Auto-demo should be driven by an independent controller and made mutually exclusive with player input through a state gate; otherwise you get input overrides, state races, or interrupted demos.

    4. Why Multi-Round Repair Often Makes Things Worse

    Multi-round repair failures usually stem from a missing engineering loop rather than a single weak capability:

    1. Context drift: Each round only addresses the current symptom while original constraints are forgotten, so fixes drift away from the overall structure.
    2. Patch-style modification: Patches are applied separately to rendering, input, and state without a unified state model.
    3. No regression tests: After fixing a button, existing features such as characters, score, and auto-demo are not re-verified.
    4. Implicit constraints left implicit: Constraints like “characters must always remain in the render list” or “the button is only clickable in the playing state” are not written as assertions, so they are easily broken during repairs.

    5. A Practical Evaluation and Repair Workflow

    A recommended workflow is “baseline cases — layered repair — automatic smoke tests — regression gating.”

    First, establish minimal acceptance assertions for the scenario:

    • The page loads without uncaught exceptions.
    • Clicking start transitions the state to playing.
    • Character coordinates change with input.
    • Shoot, pass, and steal buttons trigger their corresponding events.
    • Auto-demo can start and does not conflict with input.
    • The ended state is recoverable.

    Then repair layer by layer—visual, interaction, state, performance—changing only one layer per round and recording the impact scope. After every change, run the automatic smoke script and collect state snapshots and logs. Finally, enforce a regression gate: modifications that fail existing test cases may not be merged.

    For the evaluation environment, general-purpose cloud capabilities such as container platforms, logging services, and monitoring/alerting (for example, those offered by Baidu AI Cloud) can be used to isolate test cases, collect runtime logs, and raise alerts on exceptions, making the multi-round repair process trackable and comparable.

    6. Code Example: Constraining Interaction and Repair with a State Machine

    1. const state = {
    2. phase: "ready", // ready | playing | demo | ended
    3. actors: [],
    4. score: 0
    5. };
    6. function startGame() {
    7. if (state.phase !== "ready") return;
    8. state.phase = "playing";
    9. initActors();
    10. startLoop();
    11. }
    12. function bindAction(button, action) {
    13. if (!button) return;
    14. button.addEventListener("click", () => {
    15. if (state.phase !== "playing") return;
    16. action();
    17. });
    18. }
    19. function update(dt) {
    20. if (state.phase !== "playing" && state.phase !== "demo") return;
    21. for (const actor of state.actors) {
    22. if (!actor.visible) continue;
    23. actor.x += actor.vx * dt;
    24. actor.y += actor.vy * dt;
    25. }
    26. }

    This structure separates state transitions, input gating, and entity updates, which makes problems easier to localize across repair rounds: for a dead button, check bindings and the state gate first; for disappearing characters, check entity visibility and the render list; for abnormal movement, check the time step and coordinate space.

    7. Conclusion

    Evaluating an LLM’s ability to generate interactive games should not stop at whether a single generation “looks right,” but at whether the result still “runs, regresses cleanly, and is observable” after multiple repair rounds. Visual fidelity, closed-loop interaction, state-machine consistency, auto-demo isolation, and regression verification should together form the evaluation framework. Only by upgrading evaluation from visual impression to engineering-grade verification can we accurately identify a generation solution’s real delivery capability in complex interactive scenarios.