Entry 04 · October 2025

Chemotaxis, barriers, nutrients & save/load

Four systems went in this month, and one of them changed how the whole game feels to play.

A dendritic cell collecting from clusters of nutrients, with a single bacterium approaching from the right.

Back from a holiday, back in the passenger seat. I had a list of four things I wanted in before the end of the month and, unusually, all four went in. Here's what each one is, and what it broke on the way.

Bacteria stopped walking in straight lines

Real bacteria don't steer. They swim in a roughly straight line for a moment, stop, tumble to a random new heading, and swim again. When the chemical environment is getting better they tumble less often, so over time they drift up the gradient without ever knowing which way it points. It's called run-and-tumble, and it is a much better pathfinding algorithm than anything I would have written.

Swapping straight-line movement for this was maybe twenty lines of code and it completely changed the feel of a wave. The swarm now spreads, hesitates, bunches at gradients. You can read its intent.

The best design decision I made this month was to stop designing and copy what the cells already do.

The part that broke

Bacteria are pooled objects, so they get reused rather than destroyed. Any leftover state from a previous life comes back with them — a stale target, a remembered last position. That produced bacteria that spawned already convinced they were mid-fight with something on the other side of the map. The fix is boring but worth writing down: everything gets cleared on re-enable, not on creation.

Platelets can build now

Platelets were the last unit with nothing to do. They now place barriers, which means a wound can actually be sealed instead of just defended forever. Placement snaps to the tissue grid and costs resources, so walling off a breach is a real trade against spawning more cells.

Barrier blocks placed along the lower tissue edge while a dendritic cell scouts past two bacteria.
Fig. 2 — Barrier blocks placed along the lower tissue edge. Cost scales with span, so the cheap option is always to seal early.

Nutrient fields are worth fighting over

  • They attract bacteria, which lets you predict where a swarm will go.
  • They're hidden until one of your cells gets close, so scouting matters.
  • Activating one takes a cell out of the fight for a few seconds.

And the save system

Least glamorous, most necessary. Unit positions, research state, barriers, discovered fields and wave timers all serialise now. The trick that made it manageable was keeping every saved object as a small plain data type rather than trying to serialise Unity's own classes:

// Vector3 can't be saved directly, so it becomes a tiny record first
public static Vector3Dto ToDto(this Vector3 value)
    => new(value.x, value.y, value.z);

Next month: the tech tree, which currently contains several upgrades that do nothing measurable. Time to be honest about that.

Join the battle

One email when something actually works.

Roughly monthly. Devlog entries and demo builds. Unsubscribe in one click.