More fun with world generation
Hi subscribers, I've spent much of this week chipping away at the worldgen game in the small gaps of free time that I have, so here's an update on this bit of silliness. It's gotten to a surprisingly interesting place even though there's plenty of flaws and quirks to it.
As I mentioned on one of my vacation posts, I wanted to play with the idea of game-like thing that simulates a fantasy world, with the intent of seeing if I can make interesting narratives happen. The code for anyone who wants to play with it is on github.
When I first shared the project last month, I was in the middle of getting the game to sensibly balance out, which took a lot of manual testing and tuning. This time, I managed to make that process easier by doing a couple of things:
- Create a headless simulation mode that can be invoked from the command line
- Have the sim output statistics every tick on properties we care about, like # of settlements, how much territory they have, population, the various states of characters etc
- Get Claude to build tests that can run the sim for a period and check of the statistics are within boundaries that I define. For example, we don't want the number of settlement ruins to get ridiculously high (a real issue w/ a past tuning version)
- Allow Claude to tweak the parameters of the sim to get the sim to behave closer to what I want things to be, keep iterating on parameters until things settle down
While this parameter-search loop doesn't solve all (or even many) of the balance issues within the sim, it helps keeps the most fundamental things within a workable range. That way, when I add a new mechanic or something that has deep and unpredictable effects, I don't have to do the work manually.

Once that base balancing hurdle was cleared, it was a lot easier to start adding interesting mechanics. For example, characters now have "goals" now which are things they are encouraged to complete and will boost their mood if they succeed. Goals include wanting to wander and explore, or to settle a new settlement, or to create a new piece of artwork, obtain an artifact, or form a bond with another character. This forms the basis for how a civilization can expand (the ruler can delegate a goal to settle out to another character). A lot of other things are also tied into goals.

Wars of conquest are also simulated now when the borders of difference civilizations come into contact. In theory alliances are also possible but wars are much more common in practice. Wars help push the overall narrative of the game because characters can participate in battles, and also can fall into grief cycles if a character they have a social bond with dies.
But probably most interesting right now is that we finally have enough moving pieces around that we can look at entire civilizations, pull all the events that have to do with them and their population, and feed that into an LLM to generate civ-level narratives.

While narratively still very simplistic and one-dimensional (it's primarily about ruler succession and conquest), it does show some promise. I just have to layer on more interesting mechanics and details, right? One hilarious bug that I found during this writeup is how the game allows anyone to become a ruler, including newborns. Even in the story below, you see this utterly deranged sentence: "though he himself arrived in the Shire by birth in Year 2, his immediate efforts shaped a new life for five hundred souls."
[Example Cilivzation-level history narrative of "Elmo's Shire]
From the records preserved by the Chronologers, we see the passage of millennia, etched into the very stone and memory of Elmo’s Shire. Our history is not merely a listing of dates, but the slow accumulation of resolve—a chronicle defined by conflict, renewal, and an unyielding martial spirit.
The genesis of this grand civilization can be traced to Year 2. It was at this nascent point that our founder, Elmo “of the Green Hill,” established the first beacon of permanent habitation: the settlement known as Deepbridge. Though he himself arrived in the Shire by birth in Year 2, his immediate efforts shaped a new life for five hundred souls. In those earliest days, while the community faced its initial hurdles—evidenced by a disease outbreak in Year 8—Elmo not only secured the foundation of our people but also established a nascent culture, creating works of art noted records from both Year 6 and Year 17.
The early decades tested Deepbridge severely. A subsequent outbreak of plague broke the community’s heart in Year 57, followed by another crisis in Year 78. Yet, the Shire persisted through these biological scourges, learning resilience with every passing season.
As the century turned and the tides of leadership changed, a new era dawned with Perla “the Generous.” She ascended as the third ruler in Winter of Year 37, succeeding Caela. Her reign was marked by cultural achievements; she created artistic works noted both when she was still young (Year 33) and again during her mature years (Year 45). However, the stability of Deepbridge proved precarious, suffering disease outbreaks in Year 57 and Year 78, suggesting that prosperity did not guarantee health.
[... it goes on ...]How generation currently works
Right now, the narrative generation for characters or civs is relatively simplistic. Run a series of sqlite queries to dump out events from the game world for the entities in question, have some heuristics to filter out noise, then feed the data into an LLM with a prompt. To keep things cheap, I'm running `gemma4-e4b` on Ollama to generate the narratives. It does a surprisingly acceptable job for now.
Eventually in the future I'll actually tune the prompt that's used to generate the narratives, but the ones living in the scripts/ folder are sufficient for testing.
Things I'm working on currently
The main "feature" I'm fleshing out right now is the ability to "zoom in" on the game. Currently the world sim runs 1-tick = 1 season. There's just 4 ticks to the year. Each tile on the map is a giant 10km x 10km plot of land. But what if you want to "live" in that world in the sense of actually interacting with the characters and cities that exist? Surely you need to zoom in somehow in space, while also allowing time to move more naturally. The biggest challenge then is getting this micro-sim world to somehow stay consistent with the macro-sim world. And that's got all sorts of funky design challenges to muddle through.
Another big issue right now is that characters cannot cross bodies of water. They can't even wade across a river. There's also no real concept of ships and ports, so a world that has multiple landmasses will very often have all the characters clustered on just one of the landmasses.
On top of that, the world itself constantly needs more mechanics to be interesting. Commerce and trade, combat, more realistic geography, more disasters besides 'generic disease', more interactions between characters. Right now there's a very simple sketch of a world that somewhat functions as a simulacrum, but it's not "satisfying" yet. So I'll keep coming up with interesting things to layer on until it tips over to that point.
I'm not sure why I find this whole thing so much fun to mess with, but here we are.