Skip to main content
← All Posts

I was rounding your ore away to nothing

Short month. 41 commits, with an eight-day gap in the middle I’m not going to invent a reason for. But what landed is the whole economic spine of the game, so it’s worth writing up.

Starwright’s economy is five pieces and they went in in order. One unified recipe table instead of crafting logic scattered across systems. Station cores with module slots. Facilities that run discrete jobs at a rate scaled by available power, so crafting isn’t instant anymore. Extraction platforms you anchor to a giant or a gas giant and leave running, with their own minimap glyphs and a key to collect from them. And hauling drones — real ships inside the simulation, with routes you draw on a map, that load, unload and come home.

That last one changed how the game feels more than I expected. Setting up a route and flying off to do something else, knowing material is moving without you, is a different game to one where everything happens where you’re looking.

The leak

Trace elements are my favourite mechanic in Starwright. Smelting leaves residue, residue builds up, and what you refine later depends on what you refined before. The economy has a memory.

I was storing those amounts as floating-point numbers.

Trace quantities per batch are tiny by design. Store a tiny number as a float, add it to a running total, do that across a lot of small smelts, and some of those additions round away to nothing. Not all of them, and not predictably. The system kept working, the numbers kept going up, and a fraction of everything you smelted just didn’t exist.

It was also batch-size dependent, which is worse. One big smelt and a hundred small ones putting the same material through would give you different results. In a game about optimising a production chain, that means a player’s own experiments lie to them.

The fix was a data type. Trace buffers are integer milli-units now, scaled by a thousand in the migration, so the accrual is exact and a hundred small batches equal one big one. A correctness fix dressed up as a refactor, caught before anyone built a strategy on top of the wrong numbers.

A journal of everything

The other thing I built this month was a session journal. Every command and event recorded as it happens, with a replay tool and a digest that only shows me the failures.

This came from the same impulse as the headless QA bot I built for EchoQuest. I get a lot of value out of being able to ask “what actually happened” afterwards instead of trying to reproduce something from memory. A deterministic simulation makes that cheap: record the inputs, replay them, get the same run back.

The refactor underneath

One commit this month touched 82 files and added nearly 5,000 lines. Ships got per-ship subsystems. Stations became proper entities. The sector became a container instead of an implied thing. The clock got an explicit policy instead of an assumption.

Three save migrations in two weeks, v13 through v16, which is a lot of permanent surface to add that fast. Every one has to keep working for the life of the game. I did them because the entity model was going to get harder to change every week I left it, not because it was comfortable.

Still in development, still nothing to buy. The economy works though, and the drones get where they’re going.

— Bruno