Code Model Evaluation with a Single-Prompt Fighting Game

    This article proposes a practical benchmark for code-generation models: a single-prompt, single-file web fighting game. It explains why this task exposes architecture design, state management, real-time logic, and creative differentiation better than small algorithmic exercises. It also defines a reproducible evaluation protocol, a five-dimensional scoring rubric, runnable skeleton code patterns, common failure modes, and a path from a one-shot prototype to maintainable engineering. Readers get a concrete checklist for building a traceable, task-aligned model evaluation baseline.

    1. Why Use a Fighting Game as a Capability Probe

    When evaluating code-generation models, the most common approach is to ask for a sorting algorithm or a CRUD endpoint. The problem with such tasks is that the answer space is small and verification is cheap, so differences between models are compressed until they are almost invisible. What really separates models is generating a complete, self-consistent, runnable work with interactive depth in a single turn.

    A web-based fighting game happens to satisfy four conditions at the same time:

    • Zero external resource dependency: The model is asked for a single HTML file and cannot bring in images or audio assets. It must draw characters itself with Canvas or CSS, which directly exposes its ability to model visuals from nothing.
    • Moderate state-machine complexity: Idle, movement, jump, block, hit reaction, combo, and KO require at least seven or eight states, which tests how well the code structure is organized.
    • Strong real-time constraints: A requestAnimationFrame loop, frame-time stepping, and collision detection mean that any logic error immediately shows up as “it does not run” or “the feel is broken.”
    • Creative differentiation cannot be copied: Multiple characters are required to have non-duplicate skills, which tests divergent generation rather than memorization.

    Therefore, this prompt is essentially a comprehensive stress test: it compresses architecture design, mathematical calculation, state management, and creative generation into one call.

    2. Evaluation Protocol: How to Make Conclusions Credible

    The most common mistake in informal trials is “changing while watching,” which ends up measuring human-model collaboration rather than model capability. A fixed protocol is recommended:

    1. Single-turn direct output: Give the full prompt once, with no follow-ups, corrections, reference code, or assets.
    2. Fixed prompt: Use exactly the same input, word for word, for every model under test.
    3. Unified environment: Use the same browser, resolution, and frame-rate cap to avoid rendering differences affecting judgment.
    4. Blind scoring: Hide model sources, have multiple people score independently, and take the average to reduce bias from brand priors.
    5. Traceable and reproducible: Save the prompt, raw output, run recording, and version number to form an auditable evaluation record.

    Reference prompt (kept minimal, with no guidance):

    1. Write a web-based fighting game in a single HTML file, in the style of classic arcade fighting games.
    2. Requirements: keep skill moves simple; make character designs distinct and recognizable;
    3. ensure multiple characters have non-duplicate skills with novel mechanics; do not use any external image assets.

    3. Five-Dimensional Scoring Rubric

    Dimension Weight What to Observe Common Deductions
    Runnability 30% Opens and plays immediately, no console errors Syntax errors, undefined variables, missing event bindings
    Character modeling 20% Human proportions, facing direction, recognizable limbs Non-human geometric stacking, left-right mirroring errors
    Skill differentiation 20% Whether each character’s move mechanics are truly different Only values and colors changed; mechanics fully copied
    Visual completeness 15% Background layers, hit effects, UI layout Flat-color background, misaligned health bars, font overflow
    Code structure 15% Layering, separation of configuration and logic Three-thousand-line single file, magic numbers everywhere

    4. Illustrative Code: Three Key Snippets of a Runnable Skeleton

    1) A main loop with unified frame stepping, avoiding inconsistent feel across refresh rates:

    1. const STEP = 1000 / 60;
    2. let acc = 0, last = performance.now();
    3. function frame(now) {
    4. acc += now - last; last = now;
    5. while (acc >= STEP) { update(STEP / 1000); acc -= STEP; }
    6. render();
    7. requestAnimationFrame(frame);
    8. }

    2) A configuration-driven skill table, which is the structural prerequisite for judging whether skills are duplicated:

    1. const SKILLS = {
    2. a: [{ name: "Dash Slash", type: "dash", dmg: 12, range: 90, cd: 0.6 },
    3. { name: "Uppercut", type: "launch", dmg: 9, range: 60, cd: 0.8 }],
    4. b: [{ name: "Charged Cannon", type: "charge", dmg: 20, range: 200, cd: 1.4 },
    5. { name: "Teleport Kick", type: "teleport", dmg: 11, range: 70, cd: 1.0 }]
    6. };

    3) An explicit state machine, replacing scattered boolean flags:

    1. const F = { IDLE:"idle", WALK:"walk", ATK:"attack", HURT:"hurt", KO:"ko" };
    2. function setState(f, s) { if (f.state !== s) { f.state = s; f.t = 0; } }

    If the generated result lacks similar layering and configuration-driven structure, the code-structure score should be low even if the visuals look good, because the result cannot evolve.

    5. Common Failure Modes and Causes

    • Broken character modeling: The most common issue. It appears as arbitrary stacking of rectangles and circles, poor proportions, or fully mirrored left and right sides. The root cause is that the model lacks a stable prior for human proportions and tends to use the minimum number of primitives to finish the job. One mitigation is to add “human proportions and recognizable facing direction” to the prompt, but that is no longer a zero-intervention evaluation, so it should be recorded separately.
    • Homogeneous skills: Every character is “the same move set with a different color.” The root cause is that the model interprets “differentiation” as parameter differences rather than mechanic differences.
    • Performance collapse: Creating objects repeatedly every frame, no object pool, and excessive shadows and gradients cause frame drops on low-end devices.
    • Hallucinated assets: Generated paths that reference external images or audio leave the page blank when opened locally. The single-file constraint exists precisely to expose this early.

    6. From a One-Shot Prototype to Maintainable Engineering

    Direct output is suitable for validating ideas, not for long-term iteration. For production, four things are recommended:

    1. Split modules: Layer by core (loop and input), entities (characters and state machines), render (drawing), and data (skill configuration), with configuration and logic fully separated.
    2. Externalize the asset pipeline: Replace drawing with sprite sheets or vector assets, distribute them through object storage, and use a CDN with version numbers for cache invalidation.
    3. Observability: Integrate logging and monitoring alerts, collect first-frame time, average frame rate, and exception reports, and judge quality with data rather than feel.
    4. Deployment and rollback: Package on a container platform and use canary releases, keep the previous version for fast rollback, and run static validation on build artifacts as part of the CI pipeline.

    7. An Observation on the Architecture Side

    Recently, beyond “more compute” and “more parameters,” the industry has also been exploring recurrent/parameter-shared deep structures: reusing the same set of weights multiple times to gain a deeper effective computation path at lower parameter cost, combined with adaptive exit strategies to control actual compute overhead. This is a public research direction, and its benefits vary greatly by task type. It is more favorable for tasks that require multi-step reasoning and long-chain code generation, and may not be cost-effective for short-output tasks. Evaluation should be based on the task distribution, not on architecture names.

    8. Conclusion and Checklist

    Using “generate a fighting game from one sentence” as a probe is valuable because it breaks the unquantifiable idea of “smartness” into engineering metrics that can be scored. Before putting it into practice, confirm:

    • Whether the prompt is word-for-word identical and zero-intervention;
    • Whether scoring is blind and averaged across multiple people;
    • Whether raw output and run recordings are retained;
    • Whether “good-looking visuals” and “maintainable structure” are scored separately;
    • Whether failed samples are attributed to causes rather than only given a total score.

    There is no absolute answer for model selection, only an answer that matches the task distribution. Building your own reproducible evaluation baseline is more valuable in the long run than chasing any single leaderboard.