Evaluating LLM-Generated Interactive Programs: From Visual Polish to Logical Validation
Large language models can quickly generate runnable interactive games and visualizations, but a polished page does not prove that the program is correct. This article explains how to evaluate generated programs across rendering, interaction, rules, and algorithms; separate visual quality from functional correctness; turn natural-language requests into testable specifications; validate maze pathfinding and Q-learning demos; debug 3D geometry, collision, and camera issues; and use layered testing and targeted feedback to improve generated results.
1. Evaluating Generative Coding Beyond “It Runs”
When a large language model is asked to generate an interactive mini-game or visualization, it can often produce an initial page very quickly. The background, lighting effects, animations, and basic controls may all be present. However, the visual completeness of such a result does not directly prove that the program is correct.
A runnable page involves at least four layers:
- Rendering layer: Whether elements are drawn as intended, with clear colors, dimensions, and stacking order.
- Interaction layer: Whether keyboard, mouse, or touch input is received correctly.
- Rules layer: Whether movement, collision, win/loss conditions, and similar behaviors follow the game rules.
- Algorithm layer: Whether pathfinding, solving, or policy updates are actually implemented rather than merely shown through animation or text descriptions.
If you only check whether a page appears, it is easy to mistake “having an interface” for “having complete functionality.” A more reliable approach is to break the requirements into verifiable behaviors and check each one individually.
2. Visual Quality and Functional Correctness Are Separate Evaluation Axes
A common illusion in generative coding is that a visually rich page means the core functionality is complete. In reality, visual presentation and functional correctness are independent of each other.
1. Visual Elements Must Support Information
Particles, shadows, gradients, and dynamic lighting can improve the look and feel, but if the background is too dark, the board boundaries are unclear, or key objects are too close in color to the background, users cannot determine the current state. For interactive programs, visual design must first ensure readability:
- There should be sufficient brightness and color contrast between the play area and the decorative background.
- Important objects, obstacles, and target positions need stable and obvious visual encoding.
- Animations must not obscure state changes or make users misjudge where objects are.
- The page should maintain a reasonable layout at different window sizes, avoiding clipping or imbalance.
Therefore, during acceptance testing, it is useful to first turn off decorative effects and inspect the play area, objects, and status indicators on their own. If the basic information is hard to identify, even elaborate rendering cannot compensate for the interaction experience.
2. Rule Correctness Must Be Verified Through Behavior
Consider a sliding puzzle on a board. Pieces being neatly arranged is only an appearance condition. You also need to verify the board dimensions, the position of the empty space, the legal movement range, and the target layout. If the page displays a board but allows pieces to pass through other pieces, or cannot recognize a completed state, then it is only a static interface, not a game with correct rules.
Similarly, a bowling-style scene cannot be judged only by whether the ball rolls and whether pins fall. Pin spacing, arrangement, and collision volumes all affect whether players can hit the intended targets. If the model only focuses on making the pins “look like a group” without considering collision relationships, it may generate a scene that is visually similar but physically unreasonable.
3. Convert Natural Language Requirements into Checkable Specifications
Vague requirements are an important source of unstable generation results. Instructions such as “make a fun maze” or “implement a bowling game” do not specify the map structure, control scheme, collision rules, or success conditions, so the model must fill in the details itself. Those filled-in details may be reasonable, or they may differ from user expectations.
A more effective approach is to organize the requirements into explicit specifications.
1. Define Objects, States, and Actions
For a maze program, for example, at least the following should be defined:
- Which elements make up the map: walls, passages, start point, and end point.
- Where the player or agent starts.
- Which actions are allowed at each step, such as up, down, left, and right.
- Which moves are illegal, such as going out of bounds or entering a wall.
- How success is determined after reaching the end point.
- Whether reset, pause, or step-by-step viewing is allowed.
These descriptions are not formalism for its own sake; they help the model connect the interface, state, and behavior. Without state definitions, a program may draw a maze but have no executable path logic.
2. Rewrite “Works Well” as Acceptance Conditions
“Reasonable layout” and “smooth operation” are subjective expressions, and they can be turned into observable conditions. For example:
- Both the start point and end point are in traversable areas.
- At least one path from the start to the end exists on the map.
- The agent cannot pass through walls or leave the bounds.
- After execution ends, the program should clearly display success, failure, or no feasible path.
- The grid size and cell spacing should keep the whole map visible.
The more specific the acceptance conditions are, the easier it is to distinguish whether the model implemented the core functionality or only generated an appearance-only demonstration.
4. Maze Pathfinding: Validate the Environment Before the Learning Process
In maze reinforcement learning demos, it is easy to encounter a situation where “the algorithm name is correct, but the actual process is incomplete.” A page may show an agent and a map, but that does not mean the agent is learning, nor does it mean it will eventually find a path.
Validation should be split into two parts.
1. Check Environment Modeling
The environment can usually be represented as a grid. Each cell corresponds to a state; the agent is located in a traversable cell and moves between adjacent cells according to actions. Walls, boundaries, the start point, and the end point should all be explicitly represented in the program state, not distinguished only by drawing colors.
You should also check whether the map is solvable. If the start is sealed off by walls or the end is unreachable, the algorithm may fail not because of the learning method but because the test environment itself is invalid. Developers should first use simple methods such as breadth-first search to check connectivity, then judge whether the learning process behaves as expected.
2. Check Policy Updates and Termination Conditions
Q-learning is a reinforcement learning method based on state-action value estimates. It interacts with the environment and updates action values based on immediate rewards and the estimated values of subsequent states. If the demo has no actual update process and merely moves a character along a preset path, it should not be considered a completed learning algorithm.
During validation, pay attention to:
- Whether each action is constrained by legal movement rules.
- Whether reaching the goal produces a reward, and how collisions or invalid moves are handled.
- Whether there is a trade-off between exploration and exploitation.
- When each training episode ends, and whether there is a maximum step limit.
- After training, whether the policy can reliably find the target on the same map.
For educational demos, the program should also display necessary information such as training episodes, the current path, or the exploration process. This allows users to distinguish between “learning,” “executing an existing policy,” and “playing a preset animation.”
5. 3D Interactive Scenes: Geometry, Collision, and Camera Must Work Together
Problems in 3D scenes are often not limited to the appearance of models. The ball, pins, floor, colliders, and camera together determine whether the operation is credible.
For example, if the pins are spaced too far apart, the ball may hit the front row but fail to reach objects in the back row. If collision volumes do not match the visible models, users will see “contact without response” or “collision without contact.” Errors of this kind cannot be solved merely by adjusting colors or animation; the correspondence between scene geometry and physics parameters must be checked.
A layered troubleshooting approach is recommended:
- Validate the static layout first: Confirm the positions, sizes, spacing, and arrangement of objects.
- Then validate collision ranges: Keep colliders reasonably consistent with visible models, and check floor and boundary constraints.
- Then validate motion: Observe the ball’s speed, direction, bouncing, and stopping behavior.
- Finally adjust the camera and lighting: Ensure that players can clearly see the target area and key motion trajectories.
In the early stages of development, use simple geometry and solid-color materials, and add complex materials, shadows, and particle effects only after the layout and collisions are correct. This reduces visual distractions that make it harder to locate problems.
6. Use Layered Testing to Reduce Rework
The output of generative coding should not be accepted by “taking a quick look.” The following test sequence is suitable for most small interactive projects.
Step 1: Startup and Rendering Checks
Confirm that the page loads, the canvas size is normal, and there is no obvious occlusion or blank area. If errors occur before the program runs, fix the basic problems first; do not continue discussing algorithm results.
Step 2: Critical Interaction Checks
Test buttons, keyboard input, drag operations, and reset functionality one by one. Pay attention to issues such as input focus, repeated triggering, and conflicting operations. For example, are keyboard events still processed when page focus is incorrect? Does reset truly restore the state to its initial values?
Step 3: Boundary and Exception Checks
Test out-of-bounds movement, invalid operations, rapid repeated input, unreachable goals, and scene scaling. Many logic defects do not appear on the normal path but are exposed by boundary conditions.
Step 4: Core Rule Checks
Set up a group of small cases that can be judged manually for game rules or algorithms. For a maze, use maps known to be reachable and unreachable; for a sliding puzzle, test illegal moves and recognition of the final state; for collision scenes, check contact results under different directions and speeds.
Step 5: Readability and Experience Checks
Finally, evaluate color contrast, information hierarchy, animation pacing, and layout at different screen sizes. Recording functional tests and experience tests separately helps avoid mistaking subjective preferences for program defects.
7. Iterating with the Model for More Reliable Results
When the first generated result is unsatisfactory, repeatedly repeating the same request often has limited effect. A more effective approach is to provide specific feedback based on the type of failure:
- Layout error: Point out which object’s scale or spacing does not meet the requirement.
- Rule error: Describe the difference between actual behavior and expected behavior, and provide reproduction steps.
- Algorithm error: Provide the map, initial state, expected result, and actual result.
- Display error: Explain what is hard to see and at which window size it occurs.
- Structural issue: Ask the model to first explain the state representation and key flows, then modify the implementation.
You can also ask the model to first provide a design explanation, state definitions, and a test checklist, and to generate the complete code only after the plan is confirmed. For tasks involving multiple modules, implementing step by step in the order of “static layout—basic interaction—rule logic—algorithm—visual refinement” is usually easier to debug than requesting a complete application all at once.
Conclusion
Evaluating LLM-generated interactive programs should shift from “whether a page was generated” to “whether verifiable behavioral specifications are satisfied.” Visual presentation, interaction response, rule implementation, algorithm behavior, and scene physics each have distinct responsibilities, and a failure in any layer can distort the overall experience.
Breaking requirements into objects, states, actions, and acceptance conditions, then testing by layer and providing specific feedback on failures, can significantly improve the controllability of generated results. For developers, models are better used as aids for implementation and iteration; final quality still depends on clear design, repeatable testing, and human judgment.
