Evaluating AI-Assisted Programming: From a Minesweeper Prototype to Engineering Delivery
This article proposes a verifiable approach to evaluating AI-assisted programming, using a Minesweeper game as a small but representative sample. It covers requirement clarification, separation of data, rules, and presentation, correctness checks for core algorithms, test coverage beyond startup, objective quality dimensions, and an iterative delivery workflow. Readers will learn how to move from subjective impressions of code generation to acceptance criteria, rule invariants, deterministic and randomized tests, and controlled engineering delivery.
1. Ask the Right Questions Before Evaluating AI Coding
When an AI coding tool generates a large amount of code from a single prompt such as “write a complete Minesweeper game,” the first impression is often one of efficiency: interface layout, event handling, and game rules that would normally require manual organization can now form a draft in one interaction.
From an engineering perspective, however, “can generate code” and “can complete a project” are not the same thing. Code that starts only proves that the most basic execution path works; a complete-looking interface does not mean exception handling, state consistency, and boundary conditions are correct.
Evaluation of AI coding capability should therefore move from subjective experience to verifiable questions:
- Did the tool correctly understand the task and explicitly state key assumptions?
- Did it implement the complete rules, not just a similar-looking interface?
- Does it remain stable under boundary inputs and continuous operations?
- Does it have a clear structure that is easy to modify later?
- Does it provide run instructions, test methods, and known limitations?
Minesweeper is a useful observation sample because it is small but involves random generation, two-dimensional data structures, neighborhood calculation, region expansion, state management, and input interaction. It can reveal a model’s ability to build a local application, but it cannot directly represent its delivery level for large business systems.
2. What Engineering Decisions Are Hidden Behind a One-Sentence Requirement?
“A complete Minesweeper game” sounds clear, but it actually contains many unspecified conditions.
The first is the runtime form. A user may need a single-page browser game or a program embedded in an application container. Different runtime environments require different file organization, input events, and deployment requirements. If this is not clarified, the generated result may be functionally correct but unable to run in the target environment.
The second is rule conventions. Does the first click guarantee safety? Is flagging supported? Can an revealed numbered cell trigger batch revealing of surrounding cells? Does the game timer start when the page opens or on the first valid operation? These are not simple interface details; they are design decisions that affect data structures and state transitions.
The final point is delivery scope. Supporting only mouse operation on desktop is a different task from also supporting touchscreens; local entertainment only is clearly different from leaderboards, accounts, and cross-device synchronization.
A more reliable approach is to turn vague requirements into a minimal acceptance checklist:
| Dimension | What needs to be clarified |
|---|---|
| Runtime mode | Target environment, startup steps, whether network access is required |
| Board configuration | Rows, columns, mine count, and input boundaries |
| Basic operations | Reveal, flag, unflag, restart |
| Rule strategy | First-click safety, region expansion, win/loss determination |
| Interaction feedback | Remaining flag indicator, timer, end-game display |
| Adaptation requirements | Desktop operation, touch operation, keyboard accessibility |
| Delivery materials | Source code, run instructions, test checklist, known limitations |
AI coding tools can fill in some requirements based on common patterns, and this is a valuable capability. But “automatic completion” cannot replace requirement confirmation. The correct engineering habit is to have the tool list its default assumptions and then have the developer confirm them, rather than treating inferred behavior as the user’s requirement.
3. Build the Rule Model Before Implementing the Interface
The most common problem in a Minesweeper project is mixing rule calculation with interface updates. When a cell is clicked, the code simultaneously changes page text, adjusts counters, checks win/loss, and recursively processes neighbors. This looks convenient in the short term but makes errors difficult to locate later.
A more robust structure divides the program into three layers.
3.1 Data Layer: Describe the Board and Game State
Each cell needs to record at least:
- whether it contains a mine;
- whether it has been revealed;
- whether it has been flagged;
- the number of adjacent mines.
The overall game also needs to record row and column dimensions, mine count, current phase, start time, and other information. The current phase can use a finite set of states such as “not started, in progress, won, lost.”
The key to state design is not the number of fields but the invariants. For example:
- A finished game no longer accepts operations that change the board;
- A revealed cell cannot be flagged;
- The adjacent-mine count of a non-mine cell should equal the actual neighborhood count;
- The actual number of mines on the board must match the configuration.
These constraints should be maintained by the core logic, not indirectly guaranteed by whether interface buttons are clickable.
3.2 Rule Layer: Handle Operations and State Transitions
The rule layer is responsible for random mine placement, neighborhood calculation, cell revealing, flag toggling, and end-game determination. It does not need to know cell colors, button styles, or animation effects.
This separation makes testing more direct: without opening the page, you can construct a fixed board and verify which cells are revealed after an operation and whether the game state changes.
3.3 Presentation Layer: Map State to Visible Feedback
The presentation layer only reads state and presents results, while converting user operations into events that the rule layer can understand.
When model-generated code maintains this boundary, adding themes, adjusting board layout, or supplementing touch interaction later does not require reworking the core algorithm.
4. Correctness Checks for Core Minesweeper Algorithms
4.1 Random Mine Placement Cannot Rely Only on “Looking Random”
A common simple implementation repeatedly selects random coordinates until the specified number of mines is placed. It must avoid duplicate placements; when mine density is high, repeated sampling may also produce many invalid attempts.
A clearer approach is to build a set of available positions, randomly shuffle the positions, and then select the specified number of positions for mines. Whichever method is used, verify that the mine count does not exceed the number of available cells and check the actual number placed.
For a local game, ordinary pseudorandomness is usually sufficient for entertainment. If random results involve rewards, competition, or entitlements, predictability and cheating risks require further consideration, and the same security assumptions should not be carried over.
4.2 First-Click Safety Requires an Explicit Implementation Strategy
If the first click must not hit a mine, the minefield can be generated on the first valid reveal, excluding the clicked position from candidate positions.
If the first click must also expand a blank area, its surrounding neighborhood must be further excluded. This reduces available positions, so the compatibility of board size and mine count must be rechecked.
These two strategies produce different experiences and should not be conflated. Generated code should clearly state which one is used and explain how extreme configurations are handled.
4.3 Blank Region Expansion Must Avoid Repeated Visits
After revealing a cell with zero adjacent mines, continue revealing connected zero-value cells and the numbered boundary around those zero-value cells, but do not expand through the numbered boundary into unrelated areas.
A queue can be used for iterative traversal. Below is illustrative pseudocode:
If the starting cell is already revealed or flagged:ReturnIf the starting cell contains a mine:Set the game to lostReturnReveal the starting cellIf the starting cell has zero adjacent mines:Add the starting cell to the queueWhile the queue is not empty:Remove a zero-value cellIterate over its valid neighbors:If the neighbor is already revealed, flagged, or contains a mine:SkipReveal the neighborIf the neighbor has zero adjacent mines:Add the neighbor to the queue
The key point is to mark a cell as revealed before adding it to the queue, preventing the same cell from being added multiple times by different neighbors. For larger boards, iterative traversal also avoids call-stack issues caused by deep recursion.
4.4 Win Determination Cannot Depend on Flag Count
“The number of flags equals the number of mines” does not mean the player has won, because flags may be placed in the wrong positions.
A more direct condition is:
The number of revealed non-mine cells equals the total number of cells minus the number of mines.
Flags are only markers that help the player reason. The remaining-mine indicator in the interface is usually an estimate calculated from the total mine count and the current flag count; it does not mean the program has confirmed that all markers are correct.
5. Tests Should Cover Rules, Not Just Successful Startup
After code generation, first verify the startup flow, but do not stop there. One smooth playthrough only shows that one operation path works; it does not prove that all branches are correct.
5.1 Use Fixed Boards to Test Core Rules
Random boards are suitable for experience but not for reproduction. Rule tests should use predetermined mine layouts to verify neighborhood counts for corner, edge, and center cells, as well as the expansion range of blank areas.
Pay special attention to testing:
- A numbered cell reveals only itself;
- A flagged cell is not accidentally revealed by region expansion;
- Clicking a mine immediately enters the lost state;
- Revealing the last non-mine cell enters the won state;
- Repeatedly clicking an already revealed cell does not repeatedly increase counters.
5.2 Use Randomized Tests to Check Invariants
Across multiple generated boards, automatically check mine counts, neighborhood statistics, and state constraints. Randomized tests cannot replace deterministic cases, but they can supplement layout combinations that are difficult to enumerate manually.
If random seeds or generated board data can be saved, problems can be reproduced instead of relying on descriptions such as “it happened once earlier.”
5.3 Check Input and Lifecycle
Continuous clicks, rapid resets, difficulty switching, and operations after the game ends are paths that are easily overlooked.
The timer especially needs checking: whether old timer tasks are cleared on restart, whether it stops after the game ends, and whether repeated initialization creates multiple tasks. If the timer display relies on periodic refresh, calculate elapsed time from the actual time difference rather than treating each refresh as exactly one second.
Touch devices have no right mouse button, so long-press or an explicit flag mode is needed. Keyboard users need visible focus and operable controls. These are not merely “interface optimizations”; they are part of the delivery scope.
6. How to Objectively Evaluate Code Generation Quality
The amount of code is not a quality metric. A program with thousands of lines may contain a large amount of duplicated logic; a concise program may also be easier to maintain because its rules are complete and responsibilities are clear.
More useful evaluation dimensions include:
Requirement compliance. Are all acceptance items implemented? Are default assumptions transparent? Have accounts, network dependencies, or extra features been introduced without being requested?
Correctness. Do core rules, boundary conditions, and state transitions pass tests? Do regressions appear after changes?
Maintainability. Are data, rules, and presentation separated? Can important logic be verified independently? Is there excessive duplicated code?
Delivery usability. Are startup methods, runtime environment, and known limitations documented? Can the recipient reproduce the result according to the instructions?
Modification efficiency. When adding “adjust difficulty” or “support touch flagging,” how many places need to change? Can the model explain the impact scope and keep existing rules stable?
When comparing different generation approaches, try to keep requirements, runtime environment, test cases, and modification opportunities consistent. Otherwise, a better-performing result may simply reflect clearer prompts or a more familiar task, rather than stronger overall capability.
7. Bring AI Coding into a Controlled Engineering Process
A practical way of working is not to have the tool write as much code as possible at once, but to establish an acceptance-driven iterative loop.
Step 1: Clarify the runtime form and functional boundaries, and require the tool to first output rule assumptions and an acceptance checklist.
Step 2: Build the data model and state transitions, review key invariants, and avoid letting the interface hide rule defects.
Step 3: Implement a minimal runnable version containing only mine placement, revealing, and win/loss determination.
Step 4: Use fixed boards to verify core algorithms, then supplement with randomized tests and boundary inputs.
Step 5: Gradually add flagging, timing, difficulty switching, and device adaptation, running regression checks after each change.
Step 6: Organize delivery materials, explaining run steps, test results, and scenarios not yet covered.
If the project requires uploading code, connecting to network services, or processing business data, also check sensitive information, dependency sources, and access permissions. Generated content should be treated as an engineering artifact awaiting review, not as a final answer that is trusted by default.
8. Conclusion: The Value Is in Accelerating Implementation, Not Eliminating Acceptance
Projects with clear rules and limited scope, such as Minesweeper, can demonstrate the value of AI coding in requirement completion, structure building, and draft generation. But success on a familiar subject is not enough to prove that it can independently complete complex systems, and interface effects cannot replace quality verification.
The developer’s role has not disappeared; it has shifted more toward defining problems, selecting constraints, reviewing designs, verifying results, and controlling changes.
Whether AI coding is truly effective should ultimately be judged by whether it helps a team obtain correct, maintainable, and reproducible results at a more controllable cost under clear requirements. Code generation is the starting point; verified delivery is the endpoint.
