Complex Geometric Construction Tasks: A Rigorous Benchmark for Evaluating LLM Code Generation
This article explains why simple "toy-level" HTML/CSS tests are losing their value for evaluating large language models, and argues for harder, mathematically grounded tasks. Using the construction of a regular heptagon with a marked ruler (neusis) as a case study, it shows how such problems combine mathematical correctness, numerical stability, and front-end engineering—including GIF export—into a task that genuinely discriminates between models. It also offers a reusable methodology for designing high-quality code evaluation prompts and a multi-dimensional scoring framework that separates "can it run" from "is it actually correct and complete."
1. Why “Toy-Level” HTML Tests Are Losing Their Value
For a while now, the community has been using simple HTML/CSS animations to test the coding ability of large language models—tasks like “draw a clock whose hands spin,” “make a gradient button,” or “generate a random particle background.” These tasks share a common trait: short structure, minimal state, and almost no mathematical or engineering complexity. As model capabilities have improved across the board, their discriminating power has dropped sharply—nearly every mainstream model passes on the first try, and the evaluation has degenerated into a “everyone gets a perfect score” formality.
A truly valuable capability benchmark should instead pick tasks that “look easy but have a high real barrier.” These tasks typically need to satisfy several conditions at once:
- There is a clear, objective correctness criterion, rather than reliance on subjective aesthetics;
- A mathematical modeling or algorithm-design challenge is hidden beneath a simple surface;
- Multiple technical stages must work together (rendering, animation, interaction, export) for a complete implementation;
- There is a strong constraint on logical rigor—any single misstep in reasoning or numerical computation produces a wrong final figure.
Geometric construction tasks fit these traits well, especially propositions that “cannot be completed with compass and straightedge alone and require an advanced tool.” They have both a unique correct mathematical answer and a need for real front-end engineering to deliver, making them an excellent yardstick for a model’s overall ability.
2. Case Study: Constructing a Regular Heptagon with a Marked Ruler
2.1 Mathematical Background: Why the Regular Heptagon Is Not Compass-and-Straightedge Constructible
In the classical compass-and-straightedge system, constructible numbers can only come from a sequence of quadratic field extensions. The key to the regular heptagon lies in $\cos(2\pi/7)$, which satisfies an irreducible cubic equation:
8x³ + 4x² - 4x - 1 = 0
This cubic cannot be solved using square roots alone (it belongs to the so-called casus irreducibilis, the irreducible case), so the regular heptagon cannot be constructed with compass and straightedge. This is a strict conclusion from Galois theory—not a matter of “no one has found a method yet.” If a model is not even clear on this point yet starts drawing circles and lines right away, its output is most likely unreliable.
2.2 The Advanced Tool: The Marked Ruler (Neusis / Verging)
Marked-ruler construction (neusis / verging) allows two points to be marked on a straightedge; during construction, one marked point slides along a given curve until the other marked point passes exactly through a target position. This “sliding with a marked scale” capability is equivalent to allowing the solution of cubic equations, and therefore enables tasks that compass and straightedge cannot achieve, such as angle trisection, doubling the cube, and constructing a regular heptagon.
2.3 The Construction Approach
Using a square as the initial auxiliary figure, a typical marked-ruler construction proceeds as follows:
- Take a square and construct the perpendicular bisector of its bottom edge;
- Using the bottom-right vertex as center and the diagonal length as radius, draw a circle;
- Keep the marked ruler snug against the bottom-left vertex, slide its first mark along the circle until the second mark passes exactly through the perpendicular bisector of the bottom edge;
- Then, using ordinary operations like constructing perpendicular bisectors and locating centers, fill in the remaining vertices.
The real difficulty here is not “drawing circles and lines,” but rather:
- The sliding constraint of the marked ruler is essentially a geometric intersection problem that requires solving simultaneously for two unknowns: the “intersection of the straightedge and the circle” and the “direction of the straightedge”;
- The moment “the second mark passes exactly through the perpendicular bisector” is effectively solving for a root of a cubic equation, and it must be numerically precise enough—otherwise the heptagon visibly deforms;
- The task requires “completing all the omitted compass-and-straightedge construction steps,” which means the model must not only compute but also explicitly draw every auxiliary line, intersection point, and arc.
3. Why These Tasks Can Stump Strong Models
Many people assume these problems are as simple as “a pelican riding a bicycle”-style novelty drawings, but in practice even highly capable models fail here. The reason is that the task stacks three layers of difficulty:
- Mathematical correctness. The model must first “understand” that the regular heptagon is not compass-and-straightedge constructible and that the marked ruler is required, then translate the abstract geometric constraints into computable coordinate relationships. This step alone filters out the many models that only copy common construction procedures.
- Numerical stability. Computing the root of the cubic equation and the intersection point of the sliding configuration both involve floating-point precision and boundary conditions. If the model uses a wrong approximation or simply guesses a point, every subsequent vertex will be off in a chain reaction.
- Engineering completeness. The task additionally requires “drawing only the necessary compass traces” and “exporting as a GIF.” The former requires the model to understand the distinction between a “trace” and a “frozen mark,” performing incremental path drawing; the latter requires encoding the frame-by-frame canvas into a GIF on the front end—a purely engineering challenge.
Only when all three are stacked together does the task form a benchmark with a real gradient.
4. Explaining GIF Export: An Underestimated Engineering Challenge
The task requires “adding a feature to output as a GIF.” This looks like an add-on, but in fact it best reflects engineering skill. Generating a GIF in a purely client-side environment generally requires the following steps:
- Capturing the canvas content frame by frame (calling
canvas.toDataURLorgetImageDataonce at each key state of the animation); - Quantizing each frame’s pixels to a limited palette (usually no more than 256 colors), completing color dithering and index mapping;
- Packaging per the GIF89a format: writing the file header, logical screen descriptor, global color table, and each frame’s image descriptor block and graphic control extension (setting frame delay and loop count);
- Applying LZW compression to the pixel indices, and handling details such as minimum code length, dictionary reset, and sub-block splitting.
The general flow can be organized like this:
// Pseudocode: core idea of encoding a GIF frame by frame on the front endconst frames = [];function captureFrame(canvas) {const ctx = canvas.getContext('2d');const { data, width, height } = ctx.getImageData(0, 0, canvas.width, canvas.height);frames.push(quantizeToPalette(data, width, height)); // quantize to palette}// During animation progression, capture several frames at a fixed stepfunction render(t) {drawScene(t); // redraw the current state based on time tcaptureFrame(canvas); // capture this frameif (t <= 1) requestAnimationFrame(() => render(t + step));else encodeGif(frames, 100, 0); // 100ms frame delay, loop 0 times (infinite loop)}
Whether the model writes its own LZW encoder or calls an existing solution, as long as it can run in the browser and produce a downloadable GIF, it has demonstrated a real understanding of the complete “animation → frames → encoding” pipeline, rather than only being able to draw a static image.
5. How to Design High-Quality Code Evaluation Prompts
From this case, a general methodology for prompt design can be abstracted, used to build a discriminating evaluation set:
- Define an objective correctness criterion. Prefer problems with a unique correct answer (geometry, math, algorithms) so that “right/wrong” can be verified objectively, avoiding subjective aesthetics.
- Hide the real difficulty. On the surface it is a simple drawing, but underneath it requires mathematical reasoning or algorithm design, thereby exposing whether the model is “actually reasoning.”
- Require completing all steps. Ask the model to explicitly show every intermediate process (e.g., “fill in all the omitted construction steps”), preventing it from skipping steps or muddling through with approximations.
- Add engineering-level constraints. For example, on-demand trace drawing and exporting to an animated file test rendering, animation, and encoding abilities—not just plain text generation.
- Specify boundary conditions and precision requirements. Point out which points must be exact and which may be approximated, avoiding models “equivocating” on the numerics.
6. Evaluation Dimensions: More Than “Can It Generate”
Evaluating a large model’s coding ability should not stop at “does it run,” but should establish a multi-dimensional scoring system:
- Correctness: Does the final figure match the mathematical definition (does the heptagon truly close up, are the side lengths equal)?
- Completeness: Are all required steps filled in, or are there obvious omissions?
- Robustness: Are there numerical overflows, boundary crashes, or layout breakages at different screen sizes?
- Feature completeness: Are add-on capabilities—GIF export, animation control, trace drawing—actually implemented?
- Generation efficiency: Here, objectively weigh the trade-off between “quality” and “speed.” Some high-precision tasks often require longer reasoning and generation time, and slower output speed does not necessarily mean weaker ability—it may simply mean more compute is being invested in correctness. During evaluation, latency should be recorded as an independent dimension, rather than simply equating “slow” with “bad.”
7. Practical Recommendations and Summary
For developers, this can be implemented at three levels:
- Build a library: Construct a batch of “simple on the surface, complex underneath” problems around math, geometry, and algorithms to form a reusable evaluation set;
- Stratify: For each problem, prepare a control group (generate only) and an experimental group (require completion, animation, and export), and compare different models horizontally with the same prompt to observe where the gap appears;
- Retrospect: For failure cases, check the error source frame by frame—was it a math-reasoning error, poor numerical precision, or a missing engineering implementation—thereby upgrading evaluation from “scoring” to “root-cause attribution.”
Back to the original question: can lightweight general-purpose models really take on complex reasoning and engineering tasks? A geometric construction problem like “constructing a regular heptagon with a marked ruler” gives a good answer—using the most plain HTML as a vehicle, it simultaneously interrogates four capabilities: mathematical modeling, numerical computation, front-end rendering, and file encoding. The gap between those who are stumped by such tasks and those who get it right on the first try is clear at a glance. Rather than continuing to rely on the gradually failing “toy tests,” it is better to switch the yardstick to something harder, more real, and more discriminating.
