Own project, MIT licence
Heartwood: a logic game
A fantasy tower defense game in the browser, designed as a logic puzzle: archers, druids, unicorns and ents against trolls, wraiths and an ogre warlord. Every wave is visible in advance, the simulation is deterministic and the game waits between waves. Ten levels, each built around one idea, and a five-chapter Siege on one map where the defence carries over and every chapter adds a hardship. And a Duel for two players, with no accounts and no server: each builds a defence and composes waves against the rival’s, and the whole match travels in three links.
Problem
A tower defense game is easy to make hard and hard to make fair. Numbers tuned by feel give levels that are either trivial or won by luck, and every change to one tower shifts the balance of all of them.
Projects with agents and automation have the same problem: behaviour has to be checked with repeatable runs and a measurable criterion, not with an impression.
Solution
The game logic is a pure, deterministic simulation kept apart from the drawing: the same moves always give the same result. That makes it possible to replay solutions in tests and to search for them automatically.
A look-ahead solver tries every affordable move, simulates the coming waves and keeps the best one. It wrote the reference solution of each level; the tests replay them and expect a win. A probe with a careless player, who places random defenders near the route, shows that from the third level on luck is not enough.
Before the Duel was built, a measurement showed that whoever moves second and sees the other’s plan always wins, so each player plays both sides and the advantage cancels out. The result is computed in each player’s browser, so the simulation avoids maths that JavaScript engines may round differently, and CI replays every reference solution in Node, WebKit and Firefox.
- seven defenders and seven kinds of monsters; the special ones each call for one clear answer: armour, invisibility, splitting, healing, and a boss that shields its escort
- an open meadow where every defender is part of the maze, with a preview of the new route before you build
- each level ships at 50–90% of the strength the solver can still beat; from the third level on a careless player wins at most one game in ten
- Siege: a defeat restarts the chapter, and before its first wave the carried defence sells back at full value and gold is topped up until the defence is worth the floor of the chapter, so a solution from the floor proves every checkpoint winnable
- characters made from free CC0 3D models, given props and rendered to sprites by a Blender script; full keyboard play, reduced motion, English and Polish
Try it
The application loads here as you scroll and needs JavaScript. You can also open it in a separate tab.
Stack
Repository
The repository is private for now; the code is available on request.
A similar problem on your side?
Tell us about it in a few clicks. You do not need a finished specification.
We usually reply within one business day. Prefer e-mail? Write to joanna@kokot.it.