跪拜 Guibai
← All articles
Vibe Coding · Canvas · TypeScript

Entropy Rangers: AI-Generated Canvas Tower Defense Ships With 188 Green Tests, Zero Dependencies, and a Quarter of the Schedule

By 行者全栈架构师 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

AI coding agents become useful for complete artifacts when a human defines hard acceptance constraints and CI enforces them; that is the difference between a one-off demo and a shippable game. Replay-as-test generalizes to any deterministic simulation, giving AI-generated code a machine-checkable proof of correctness.

Summary

Entropy Rangers is a browser-based tower-defense strategy game: players place daemon processes on a grid data center, and each deployment rewrites the BFS flow field that enemies use to pathfind. Huawei Cloud's CodeArts agent generated all of the code; the human side defined architecture, acceptance criteria, and balance tuning. The artifact has zero runtime npm dependencies, weighs about 29KB gzipped, and passes 188 tests. Development took 21.5 hours against a hand-written estimate of about 10 days.

The engineering core is “replay as test.” Because the simulation is deterministic, one full playthrough is a regression test: a recorded command stream and seed replay headlessly and must produce the same final-state hash. Three standard matches are baked into CI, and a balance hash throws on any mismatch. The sim layer is forbidden from reading the clock, calling Math.random, importing the DOM, or using floating-point money arithmetic; custom ESLint rules and 10 CI gates enforce it. A 3000-step headless match runs in 20.46ms.

Open source code lives on AtomGit under Apache-2.0, with the game hosted as a pure static page. Adoption numbers are honestly thin: one star, zero forks, zero issues, and zero direct revenue. The monetization path is a three-layer funnel: the work builds trust, articles drive traffic to a WeChat account, and that feeds consulting, freelance, and training opportunities.

Takeaways
— Huawei Cloud's CodeArts coding agent generated all game code; the human role was architecture, acceptance criteria, and balance tuning. Total build time was 21.5 hours versus an estimated 10 days by hand.
— Entropy Rangers runs in the browser with zero runtime npm dependencies, about 29KB gzipped, pure static, no backend, database, or telemetry.
— 188 tests pass: engine 27, sim 99, replay 18. Coverage is sim 87.12%, replay 82.51%, engine 79.53%.
— One full playthrough is a regression test: command stream plus seed replays headlessly and must match a final-state hash. Three standard matches are in CI: win, loss, close win.
— Determinism rules for the sim layer: no DOM imports, no Math.random, no clock reads, no floating-point money arithmetic; custom ESLint rules and 10 CI gates enforce them.
— A 3000-step headless match simulation runs in 20.46ms.
— A floating-point sell-back formula, credits * 0.7, broke replay determinism; the fix was integer arithmetic (credits * 7) / 10 plus an ESLint ban.
— Direct income so far is 0 yuan; the stated model is a three-layer funnel: work as trust, content as traffic, and opportunities such as consulting, freelance, and training.
Conclusions

The deterministic replay pipeline carries more weight than the AI-generated code. Once a full match is reduced to a hash, “the game works” becomes an automated assertion, and a single floating-point line can be caught immediately.

AI repeatedly violated global constraints like Math.random and Date.now when they were not mechanically enforced. Output quality tracks how explicitly a human defines acceptance criteria, not how clever the prompt is.

The 21.5-hour figure is one sample; balance tuning still required three manual rounds. AI compressed structural coding while balance tuning stayed on the human side.

Concepts & terms
Entity-Component-System (ECS)
An architecture where entities are IDs, behavior lives in systems, and data lives in components; avoids tangled object graphs and lets the simulation run headlessly.
Deterministic replay testing
Recording a command stream and random seed so a simulation can be replayed exactly; any change that breaks determinism produces a different state hash and fails CI.
Flow field pathfinding
Precomputed direction grids guide all enemies at once; placing a tower rewrites the grid and instantly changes enemy routes.
Fixed timestep loop
Simulation advances in fixed 1/60s steps independent of render frames; rendering interpolates between states, preventing speed differences across refresh rates and keeping replays reproducible.
From the discussion
Featured comments
智测星球

Once you link fixed step size, instruction stream, and state hashing, 'the game runs' finally has reproducible evidence. Especially using a full playthrough replay as a regression case—this approach catches changes that break determinism better than just looking at test counts.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗