Simon Tasker

Games, apps, and the occasional detour.

Game Dev · · 7 min read

Tiny World: Nobody knows everything

Taking the omniscience away from every villager, beast and goblin on the island, so that what they do comes from what they have actually learned, and whether it broke the world.

The thing that was wrong with all of it#

The whole point of Tiny World is meant to be emergent behaviour. The people and the creatures should learn and adapt, and what they do should come out of what has happened to them.

Two weeks in, they mostly did not. They looked as though they did, because they reacted to the world constantly, but underneath almost every decision was made by asking the world a question that nobody in it could possibly have answered.

A village's platoon marched on the nearest goblin camp, although nobody in that village had ever laid eyes on it. A goblin camp chose which village to raid from the exact headcount of every village within a hundred and seventy tiles. Wolves smelled prey from eighty tiles away, in the rain. Bears knew every cave within a hundred and forty tiles. Elf healers knew about plague in any village within a hundred and sixty. And a trader setting out to find somebody to trade with walked directly to the one village they could not have known was there.

It came to a head over ore. I had just made earthquakes push up fresh rock as a way for players to find more of it, and then it struck me that villagers had no idea veins existed at all. I had added a resource to the island that only the player could ever benefit from, which is the exact opposite of the point of this project.

The audit.#

So I asked for a list of everywhere this was happening.

Claude Code sent three agents through the code in parallel, one for the villagers, one for the animals and one for the goblins, bandits, dwarves and elves. Each was looking for the same two things. Somewhere acting on knowledge it could not have, or following a fixed rule that never changed with experience.

About sixty items came back, with two findings that mattered more than the rest.

The animals had no memory at all. Every decision any animal made was a fresh scan of the world, twice a second, forever.

And none of the factions had any memory structure either. Only the villagers did, and even they bypassed it whenever asking the world directly was easier.

Then I said let us work through all of it, which is a very easy thing to say.

The pattern.#

Every single fix had the same four parts, which is a good sign that the underlying idea was right.

Something is only known once somebody has seen it. The villagers already had memories with what, where, when, who told them and how sure they are, from post two, so we added memories for veins of ore, for camps, for camps found gone, and for the creep.

Knowledge spreads the way knowledge spreads. Gossip at meals, the crier, traders and travellers, a messenger sent to a neighbour.

Knowledge goes stale. Memories fade, a camp is only known to be gone once somebody has seen the place empty, and a refuge is only known to be overrun once you are close enough to see it.

And outcomes feed back, so what happened last time changes what happens next time.

What changed.#

Villagers notice veins of ore while they are out and about, mention them at supper, and a village with no mine will take on a miner to dig the one it knows of. Camps are known only once seen and then spread by talk, and the platoons, roads, settlers and woodcutters all work from what the village actually knows.

Trade now runs on what traders found at each partner last time, and a road where traders were robbed is avoided for a while. Scouts go off somewhere the village knows nothing about and find whoever lives there. Hunters return to grounds where they have made kills, and a village keeps as many hunters as the hunting has actually fed. Some water fishes better than other water, and the fishers learn which.

Nerve grows with foes brought down and is shaken by wounds and by deaths seen. A village that has lost people to raiders keeps more on watch. One that has gone hungry keeps a gatherer out, which is the fix from post three turned from a rule into something the village learned. Guards take the gates on the side the trouble has been coming from.

And somebody lost is missed when they have not come home by nightfall, rather than the instant they take a wrong turn.

Animals remember where they were hurt and who did it, and the herd shares the fright, and their young are born knowing what their mother knew. They remember where they drank and fed well. A cheetah learns that deer outrun it and starts going for rabbits. A predator that is lying there fed or asleep gets watched rather than fled from. And a kill now leaves a carcass for the pack, with a fox turning up for the leavings once the wolves have gone.

Each goblin camp keeps a book of the villages its goblins have seen, and judges their strength by what is visible, which means a village at night with everybody indoors looks weaker than it is. A camp that knows nothing sends a scout. Goblins lost on a raid count against that village, and a war band that loses half its number breaks and runs.

Bandits go back to ambush spots that paid and keep away from ones where they lost people or saw a patrol. An elf grove only sends its healer once word of the plague has actually reached the woods. And the undead shamble home to the village they used to live in.

Did it break the world?#

This is the part I was nervous about, because a world of perfect knowledge is stable and a world of partial knowledge can starve to death.

So every phase got a soak run, a full size island run for ten to twenty five game days with learning on and off, comparing populations, food and deaths.

The animals held, and fewer of them starved, sixty eight deaths from hunger and thirst against ninety five without learning. Remembering where the water is helps, which is obvious once you see the number and was not obvious beforehand.

Carcasses nearly wrecked it. The first version crashed the boar population from about twenty five down to six, because each kill now fed the pack less than the old instant feast had, so the predators simply hunted more. Making a carcass worth what the feast had been worth put it back.

The villages gave me the worst hour of the project. One run with everything switched on showed food down to a third and people starving, and I very nearly backed the whole thing out. Two more runs on different seeds showed learning doing as well or better.

The first run was just a bad island. A single soak run is an anecdote, and I had almost thrown away a fortnight of work on the strength of one.

Goblin raids held steady, two in twelve days against one before, once camps started out knowing about the villages within marching distance of them.

How it got done.#

Two things about the process are worth writing down, since this series is partly about how the two of us work.

The first is switches. The two hundred and fifty odd automated tests depend on exact random sequences, so a change anywhere shifts who does which job everywhere. Every system's learning got an on and off switch that the test worlds turn off, and each change got its own tests with it switched on. Without that, this work would have been impossible to land.

The second is that for the faction work, the elves and the goblin hunting and the ore and the dwarves and the bandits and the creep, Claude Code ran a separate agent in its own copy of the code while it got on with the village side, then reviewed what came back and merged it. That is about seven hundred lines and seven tests done alongside the main work rather than after it.

One phase at a time, each one committed, tested, deployed and watched before the next one started. Ten deploys in a day. The server's tick time stayed between four and eleven milliseconds throughout.

What I left alone.#

Animal breeding still has a cap, and a species that nearly dies out still gets a few migrants from beyond the map. Those are the safety net that stops the island quietly emptying, and I would rather have an honest safety net than a world that dies while I am asleep.

The player's quest list still withdraws a job when its quarry is gone. That is for the player's benefit and not the villagers', and I am content with the inconsistency.

Then I wiped it.#

A fresh island, seed 75988, where nobody knows anything at all yet.

That is the real test of all this. Villages finding each other for the first time, goblins sending scouts out because they have no idea what is over the hill, wolves working out which deer they can actually catch.

The old world is archived on the server. It ran for two weeks and I was fond of it, and the new one is already more interesting, because everything happening in it is happening for a reason somebody in there could tell you.