← Devlog

Wyrmworks, four seasons in

Ember Colony taught us what the engine was missing for one kind of game. Once its content was done, we wanted a game that would push harder. That's Wyrmworks: you hunt monsters, break their parts, and feed those parts into a factory that builds better gear, while your colonists keep the works running and the valley reacts to the noise you make. It's now our flagship, and Ember Colony stays on as a proof-of-concept demo. Wyrmworks is still a working title.

Three genres that need each other

Genre mashups often end up as three games bolted together, sharing an inventory and little else. The design for Wyrmworks starts from a rule meant to avoid that: what each genre can't do on its own has to come from one of the others.

PartWhat it can't do aloneWho supplies it
The huntHarder monsters need better gear, and better gear needs refined materials in volumeThe factory
The factoryMachines need inputs the ground can't give, like sinew for belts and flame sacs for hot smelters, plus people to build and maintain themThe hunt and the colony
The colonyThere's never enough labour, and people are slow, fragile and moodyAutomation frees people up, and gear keeps them alive

The fourth piece keeps the loop from running away: the valley itself. Industry makes Disturbance (noise, smoke, light at night, rotting carcasses), and the wildlife reacts. Herds move off, predators get bolder, and the biggest monsters wake up. How hard you push is up to you.

Four seasons as one campaign

The prototype went in on 25 October. Since then we've built it in milestones, one season of the campaign each:

One early decision made all of this harder to test. Season 2 could have been its own scenario with a fixed start. Instead it carries on from whatever colony season 1 left you. The design document is blunt about it: design comes first, and if that makes something hard to test, fix the testing. So the tests start from save files captured at the end of each season, and a scripted campaign bot plays the whole thing. On all three seeds we test, it plays through to the end of season 4 and wins seasons 2, 3 and 4.

Today the game is about 14,700 lines of NAL in 22 files, with 42 test files of its own. A simulation tick on day 28 takes about 1.15 ms in a release build, inside our 1.5 ms budget.

What it pushed into the engine

The rule from Ember Colony still holds: when the game needs something NAL can't do, we fix the engine instead of working around it. One kind of fix came up again and again this month. When NAL code turned out to be doing the engine's job, slowly, we moved that job into the engine.

Here's the Disturbance pattern on its own, cut down from the game. Machines stamp noise into a field, and a herd reads the field around it:

disturbance.nal (excerpt)NAL
// Running machines stamp noise into the ground around them.
system MachineNoise {
    query: [Machine, Transform3D];
    interval: 1.0;
    transform {
        if (Machine.running) {
            Field.add("disturb", Transform3D.x, Transform3D.z, Machine.noise, 12.0);
        }
    }
}

// A herd reads the mean Disturbance around it and moves off when it's loud.
system HerdUnease {
    query: [Herd];
    interval: 1.0;
    transform {
        Herd.calm = Field.mean("disturb", Herd.x, Herd.z, 20.0);
        if (Herd.calm > 6.0) { Herd.x += 4.0; }
    }
}

The full example, with the field set up in on_start, passes nal-validate. In the game the same few calls drive which regions herds graze in, how calm the works are, and when the valley's monsters come looking.

The next step, measured first

After the fourth season come two things: tuning the whole game with its first playtesters, and a Sandbox mode, an endless game in the style of Banished on a generated map much bigger than today's 200 × 200. Before planning the map, we measured what the engine does with one. A benchmark loads the end-of-season-3 save and scatters scenery out to larger map sizes at today's density:

Map sizeEntitiesTickRender extractionSave
200 (today)9621.61 ms0.21 ms902 KB
5123,9692.14 ms1.49 ms2.4 MB
7687,8222.99 ms3.02 ms4.3 MB
102413,0684.26 ms4.87 ms6.9 MB

These are single runs on one machine, and tick times vary by about ±0.2 ms between runs. Memory was fine, at about 2.9 KB a prop. The cost is that scenery props are ordinary entities: three quarters of today's entities are static scenery, and each one costs time every frame.

The obvious fix was frustum culling, so we built it. On the 768 map it threw away 95% of the render records and saved 4% of the time. Reaching each entity to test it costs more than the reads we skip. The real fix is to stop making scenery entities in the first place and draw it as instanced batches, and the Sandbox plan now treats that as the first gate.

Wyrmworks now has its own page, with the campaign, the wildlife and what the game has changed in the engine.