Evaluating and Fixing LLM-Generated Interactive Mini-Games

    This article examines how to evaluate whether large language models can generate runnable, interactive, and iteratively repairable browser-based mini-games from natural-language requirements. Instead of judging by visual polish or a single demo, it proposes a layered acceptance framework covering launchability, input handling, state machines, entity lifecycle management, and visual-collision consistency, along with a reproducible evaluation checklist and regression practices for multi-round bug fixing.

    1. Restating the Problem: From “Which Model Is Better” to “How to Evaluate”

    The original discussion appeared to compare how two types of large models perform on the task of generating a basketball-style interactive mini-game. In substance, it raises a more general technical question: can an LLM, given a natural-language requirement, generate a frontend mini-game that is runnable, interactive, and iteratively repairable, while preserving existing functionality across multiple rounds of defect fixing?

    This is not a single-point code completion task. It is a composite engineering problem involving multi-file code generation, UI layout, event systems, state machines, entity management, collision detection, render loops, and debug feedback. Evaluation should not focus on isolated visual details such as whether a hoop is drawn or a net is visible, nor on whether one particular demo runs smoothly. Instead, a layered acceptance framework is needed: launchable, operable, completable, repairable, and observable. Only by elevating the criteria from “demo quality” to “engineering closure” does model selection become reproducible and interpretable.

    2. Key Capability Breakdown and Common Defect Attribution

    2.1 The Playable Loop: The Minimal Path from Load to End

    A playable interactive mini-game must at minimum close the loop of “initialize — start — input — update — render — end.” In the observed cases, some solutions failed at the initial stage: characters could not move, the game could not start, and the virtual shoot, pass, and steal buttons did nothing when clicked. These problems usually do not mean “the model can’t write code.” Rather, the generated result lacks a complete state machine: the initialization state never transitions into an operable state, input events are not bound to the actual DOM nodes, or the rendering layer overlays and blocks the buttons’ hit areas.

    Engineering-wise, the minimal playable loop should be guaranteed first, with visual details layered on afterward. No matter how detailed the net is drawn, if buttons are not clickable and the character cannot move, the functional chain is not closed. During evaluation, the model should be required to output a “startup path description” and an “input mapping table” — for example, keys, touch areas, event types, callback functions, and state preconditions.

    2.2 Event Binding and Hit Detection: Why Buttons Are “Visible but Not Clickable”

    Non-functional virtual buttons typically stem from three causes: event listeners bound at the wrong level, such as binding before dynamically generated buttons are inserted into the DOM; CSS stacking or transparent overlays intercepting clicks; and hit detection based on visual coordinates instead of actual element boundaries. Across multiple fix rounds, if the model only adjusts styles without changing the event delegation logic, the problem will keep recurring.

    The recommended approach is event delegation with data-attribute mapping, avoiding per-button rebinding. Illustrative code:

    1. function bindInput(root, game) {
    2. root.addEventListener('click', (e) => {
    3. const btn = e.target.closest('[data-action]');
    4. if (!btn) return;
    5. const action = btn.dataset.action;
    6. game.handleAction(action);
    7. });
    8. }
    9. class Game {
    10. constructor() {
    11. this.state = 'INIT';
    12. this.entities = new Map();
    13. }
    14. start() {
    15. if (this.state !== 'INIT') return;
    16. this.state = 'PLAYING';
    17. this.spawn('player');
    18. this.spawn('ball');
    19. }
    20. handleAction(action) {
    21. if (this.state !== 'PLAYING') return;
    22. if (action === 'shoot') this.tryShoot();
    23. if (action === 'pass') this.tryPass();
    24. if (action === 'steal') this.trySteal();
    25. }
    26. }

    2.3 State Machines and Entity Lifecycle: Fixing Bugs Must Not Delete the Characters

    One observed phenomenon was that after multiple bug-fix rounds, all characters disappeared and the court problems actually got worse. This usually indicates that the fixing strategy lacks entity lifecycle management and regression verification: the model may “eliminate the error” by deleting entities, resetting the scene, or hiding nodes, without verifying that core entities still exist. Fixes should follow the principle of “minimal changes, preserved entities, and attached regression steps.”

    Entity management should define clear boundaries for creation, update, and destruction, and a debug panel should display entity counts, states, and coordinates. After each fix, at minimum the following should be regression-tested: starting the game, character movement, shot triggering, score changes, and the end state. Without a regression checklist, multi-round fixing easily escalates from “single-point defects” to “systemic degradation.”

    2.4 Visual Consistency and Collision Consistency: Hoop, Lines, and Colliders Must Share One Source

    Another type of solution could narrate the game, move characters, and support an auto-spectator mode, but the hoop and court lines were misaligned, and characters moved slightly too fast. This shows the runnable loop was relatively complete, while the coordinate system and parameter normalization still needed strengthening. Visual elements, collision bodies, and logic coordinates should be generated from the same configuration, avoiding “one coordinate system for drawing, another for collision.”

    Collision boxes can be debugged quickly via a visualization toggle:

    1. function drawDebugBox(ctx, box) {
    2. ctx.strokeStyle = '#f00';
    3. ctx.strokeRect(box.x, box.y, box.w, box.h);
    4. }
    5. function update(dt) {
    6. player.x += player.vx * dt;
    7. player.y += player.vy * dt;
    8. }

    Movement speed should be normalized against the time step dt rather than incremented per frame; otherwise the feel varies noticeably across refresh rates. The auto-spectator mode should be independent of manual input, driven by a strategy layer on top of the state machine, to avoid coupling with manual input logic.

    3. A Reproducible Evaluation Checklist

    It is recommended to split the evaluation into six dimensions: launch success rate, input availability rate, core gameplay completion rate, post-fix regression pass rate, visual-collision consistency rate, and observability information completeness. Each dimension should have explicit operating steps and pass criteria. For example, the launch success rate requires entering an operable state within 3 seconds after loading; the input availability rate requires every virtual button click to produce the expected state change; the post-fix regression pass rate requires the core path not to degrade after each fix round.

    For model selection, the model can be required to also output: a state machine description, an event mapping table, an entity inventory, debug toggles, and regression steps. Solutions that provide these structured artifacts are generally more maintainable than those that only output large blocks of code. For batch evaluation, generation, runs, screenshots, and error logs from each round can be recorded in a general-purpose compute and logging environment, forming a comparable evidence chain.

    4. Conclusion

    The ability of an LLM to generate an interactive mini-game cannot be judged by “visual details” or a “single demo” alone. A more reasonable evaluation centers on the playable loop, event binding, state machines, entity lifecycle, visual and collision consistency, and robustness across multi-round fixing. Visual detail is a bonus, but a closed functional loop is the baseline; automated demos demonstrate capability, but regression verification guarantees engineering usability. Only by front-loading acceptance checklists, layered architecture, and debugging tools can “generatable” be advanced to “runnable, debuggable, and regression-safe,” providing an objective basis for comparing model capabilities.