Evaluating LLMs for Complex Code Generation and Constrained Reasoning: A Practical Approach
As general-purpose large language models (LLMs) are increasingly applied to code generation, complex task planning, and interactive application prototyping, objectively assessing their capabilities has become crucial. Demo effects often overestimate abilities, while single failures can underestimate potential. This article introduces an engineering-oriented evaluation methodology across three typical scenarios: interactive game generation, constraint satisfaction reasoning, and complex 3D web engineering. By breaking down real-world tasks into reproducible, measurable, and comparable evaluation sets, we can comprehensively assess models based on functional correctness, constraint compliance, engineering quality, and iterative repair capabilities.
As general-purpose large language models (LLMs) enter scenarios like code generation, complex task planning, and interactive application prototyping, objectively evaluating their capabilities has become a critical challenge for R&D teams. Relying solely on demonstrations often leads to overestimating a model’s ability, while a single failure can underestimate its potential. A more reasonable approach is to decompose real-world development tasks into reproducible, measurable, and comparable evaluation sets, assessing them across dimensions such as functional correctness, constraint compliance, engineering quality, and iterative repair capability. This article discusses an engineering-oriented evaluation methodology focusing on three typical scenarios: interactive game generation, constraint satisfaction reasoning, and complex 3D web engineering.
1. Evaluation Background and Basic Principles
The performance of LLMs in code generation tasks is rarely a binary “can write” or “cannot write” but rather shows distinct capability stratification. Some models can quickly generate a runnable skeleton but fail on complex state machines, input mapping, and boundary conditions. Others provide a complete architecture but lack playability, user experience, and performance optimization. Some excel in pure logical constraint problems but expose attention allocation and global consistency issues in large single-file engineering tasks. Therefore, evaluations should follow three principles:
- Task Authenticity: Evaluation tasks should closely align with developers’ real-world needs rather than merely testing syntax or algorithmic snippets.
- Verifiable Results: Each task must have clear acceptance criteria, including mandatory features, non-negotiable constraints, and quantifiable manual scoring items.
- Repeated Testing: Single generations are subject to randomness. The same prompt should be tested multiple times, recording pass rates, latency, and failure modes.
2. Evaluation Set and Metric Design
It is recommended to divide the evaluation set into three categories: interactive application generation, constraint satisfaction reasoning, and complex frontend engineering generation. Each category should include a basic score, an advanced score, and an engineering quality score. The basic score focuses on runnability and the presence of core features. The advanced score evaluates mechanism completeness, boundary handling, and interactive experience. The engineering quality score assesses structural clarity, maintainability, performance awareness, and iterative repair capability.
A schematic evaluation scaffold looks like this:
cases = [interactive_game, constraint_reasoning, complex_web_engineering]for model in candidates:for case in cases:for seed in range(5):output = generate(case.prompt, tools=case.tool_policy)auto_report = run_checks(output)human_report = review(output)record(model, case, seed, auto_report, human_report, latency)
Automated checks handle runnability, key function existence, input mapping, and constraint validation. Human reviews handle playability, visual organization, interactive feel, code readability, and failure mode summarization. Both are indispensable.
3. Case Study 1: Interactive Fighting Game Generation
The task requires generating a stickman fighting web game, including blocking, normal attacks, double jumps, dodging, five types of elemental skills, enemy AI logic, scenes, and complete mechanics. The key to this task is not “drawing a stickman” but state machine design: the character should have states like idle, move, jump, attack, hit, block, dodge, and skill cast, along with handling state transition priorities, cooldowns, collision detection, and enemy decision-making.
Observations show significant differences among evaluated solutions. Some only implement basic attacks and simple movements, lacking block and skill mechanics. Others generate fairly complete 3D scenes and floating platforms but fall short in operational feel and gameplay. Some perform better in skill richness, character morphing, combo attacks, and scene camera movement. This indicates that a model’s capability is reflected not just in code volume, but in its ability to understand and decompose abstract requirements like “game mechanics.”
Scoring should focus on checking: whether movement and jumping work normally; whether attack, block, and dodge have mutual exclusion and priority; whether double jumps are count-limited; whether the five skills have independent effects and cooldowns; whether enemies feature pursuit, attack, retreat, or state judgment; and whether the scene has boundaries and collisions. Common failure modes include incorrect input direction mapping, inability to exit states, skills providing only visual effects without hitboxes, and simplistic enemy logic.
4. Case Study 2: Constraint Satisfaction and River Crossing Problem
River crossing problems involve multiple characters, boat capacity, rowing permissions, and predation constraints, making them typical state search and constraint satisfaction tasks. The difficulty lies in the fact that every move changes character distribution while simultaneously needing to satisfy boat capacity, driving permissions, and safety constraints; some seemingly feasible steps can lead to dead ends later. The model must maintain state, check constraints, backtrack, and output the solution in clear steps.
Under zero-tool-calling conditions, one evaluated solution provided a feasible solution four out of five times and responded faster than some comparison solutions. This result suggests that on logic puzzles with clear constraints and a manageable state space, models with strong reasoning chains can achieve high pass rates. However, evaluation cannot stop at the final answer; the model should be required to provide state changes for each step, and a script should verify if each step satisfies the constraints. If a model only provides the final sequence without intermediate validation, points should be deducted.
5. Case Study 3: Single-File Voxel Sandbox Engineering
The complex 3D web engineering task requires implementing a voxel sandbox in a single web file: terrain and tree generation, creatures, block placement and destruction, infinite world, chunk loading, day-night cycles, weather, lighting, and performance optimization. This task simultaneously tests rendering organization, input mapping, physical collision, chunk scheduling, and performance budgeting.
Common issues observed include reversed forward/backward key mappings, non-functional jumping or flying, and abnormal movement despite correct block interaction. Some solutions successfully implement infinite worlds, chunk loading, and day-night cycles but still suffer from key mapping defects. In the optimization phase, requirements add texture details, lighting, time progression, day/night weather, infinite terrain, and performance optimization. At this point, the model must demonstrate the ability to “perform local refactoring on existing code” rather than regenerating a seemingly complete but unmaintainable single file.
Scoring for this type of task should be divided into: whether basic interactions are correct; whether world generation is stable; whether chunk loading handles boundaries; whether the render loop shows performance awareness; whether state updates are decoupled from input; and whether the code features readable module boundaries. A single file does not mean a lack of structure; excellent results usually form clear partitions within the file, such as config, input, world, rendering, entity, and UI.
6. Observations and Problem Attribution
Across the three tasks, a common pattern emerges: models often perform well in “local code correctness” but easily lose points on “global consistency and long-range constraints.” State machines in interactive games, multi-step constraints in river crossing problems, and input mapping and chunk scheduling in voxel engineering essentially all require the model to maintain goal consistency over a long context. If attention allocation is poor, problems like contradictions, omitted constraints, reversed keybindings, and half-implemented mechanics occur.
Therefore, evaluating a model requires more than a single demo; it demands a capability matrix: code runnability, requirement coverage rate, constraint pass rate, interactive playability, performance awareness, iterative repair success rate, average latency, and failure modes. For enterprise R&D scenarios, attention should also be paid to whether the generated results are easy to review, whether they integrate with existing engineering standards, and whether they can undergo continuous integration and quality tracking within general infrastructure like container platforms, logging services, and monitoring alerts.
7. Engineering Implementation Recommendations
- Establish a tiered evaluation set: Basic tasks test syntax and single-file runnability; advanced tasks test state machines, constraint search, and complex engineering organization; comprehensive tasks test iterative repair and performance optimization.
- Prioritize automated testing: Establish scripted checks for input mapping, core functions, constraint validation, and key interactions to reduce purely subjective judgments.
- Retain human review: Playability, visual organization, interactive feel, and code readability still require developer verification.
- Record failure modes: Compared to a single score, failure modes are more instructive for prompt optimization, tool-calling strategies, and model selection.
- Emphasize reproducibility: Fix prompts, acceptance scripts, and repetition counts, and record latency and environmental differences in the results.
8. Conclusion
The capabilities of LLMs in complex code generation and constrained reasoning are sufficient to support prototyping and partial engineering assistance, but they are far from the point of “generate once and deliver.” A more professional evaluation approach transforms demonstrative tasks into reproducible evaluations, subjective feelings into multi-dimensional metrics, and single results into repeated statistics. For R&D teams, the real value lies not in chasing a single-point demo, but in building an evaluation system that can continuously answer: what can the model do, under what conditions is it reliable, and can it be repaired upon failure?
