Mailbag: World Simulation for Story Generation

Hi Emily,

not sure if this is too specific a question, but I wonder if you can help me out:

Last NaNoGenMo I started out on doing a more sophisticated version of Meehan’s Talespin. I ended up doing lots of planning, but not too much implementation, so I’m going to continue my efforts this year. The biggest part of it all seems to be a world simulator. This would be where all the actions the characters are planning to do get executed. In a way this seems very similar to what is part of every IF/adventure game (locations, objects, etc), and I have programmed some of those in my micro computer days on a ZX Spectrum… But I feel this needs to be more sophisticated (and on a larger scale), and general, as there will be a multitude of possible actions that can modify the world state. And it might also have to be ‘fractal’ (for want of a better word), as there is landscape in the wild, cities (which are in the landscape, but consist of many locations where there would otherwise just be a single location of forest), and rooms in houses in cities, etc.

Are you aware of any systems in existence that I could use for that? I am kind of hoping it would be similar to a physics package for arcade games, a ready-made package that I can slot my content data and planner actions into. Or do I have to write my own?

Any pointers much appreciated!

I’ll try to answer this in its own terms below, but first I feel like those answers should come with some warnings.

This is presumably obvious, but there is no such thing as a generic world simulator. Any simulation is making decisions about what to model and what to ignore, what level of abstraction to use, what kinds of state are interesting to preserve, and so on. It’s misleading to think of “a world simulator” as “like” a physics engine. A physics engine is a type of world simulator, one that focuses on a comparatively well-defined kind of state: position, velocity, acceleration, elasticity, and so on. (I don’t mean it’s easy to write a good one! Just that the domain of simulation is reasonably defined.)

Text adventure world models tend to focus on rooms, furnishings, and items of the proper size to be carried by a human being, but that’s also very much a subset of what you might theoretically want to model. Items that are abstract (“love”, “communism”), intangible (“the smell of grass”, “a traumatic memory”), larger than a room (“Antarctica”), or smaller than a human being could pick up (“ant”, “quark”) are less likely to be simulated — though of course some of us have worked on extending the world model to include support for conversation topics, knowledge, and relationships.

Moreover, the choices you make about what to simulate will very heavily affect what kind of story you get out the other end. Finally, the way in which your simulation is described will affect how easily it can be plugged into a planner system.

I’d also warn against thinking of the content data as a minor aspect of the system. It’s common for research on story generation to focus on the process: is this grammar-based, is it a planner, is it partially ordered or not, are we forward-chaining or backward-chaining (or a little of each), are we planning the events of the story separately from the discourse layer, how are we measuring coherence and novelty (if those are even our concerns at all). Those are all interesting questions to ask, but the features of the content data also make a very significant difference to output quality, and a corpus implicitly encodes a lot of things about the possible story space that may not be inherently required by the generative method.

In every project I’ve worked on where there was a target output quality (as opposed to toy or experimental projects), most of my development time on a first release has gone into working and reworking the content data, rather than refining the process of generation. Once the qualities of a good data set are well understood, it’s possible to make additional data sets that conform to those expectations in significantly less time, and sometimes to support the process with tooling. But I tend to regard experiments in story generation to be fundamentally unfinished unless the experimenter also presents reasonably polished artifacts of their generative process. If they’re just describing a process and leaving high-quality artifact creation as an exercise for the future, then most of the work is (in my experience) still ahead of them.

So. That is the end of my speech. Now that we’re done with warnings:

An IF world model might provide some of what you need, if you’re focused mostly on actions that involve moving objects around and changing object state. After the Spectrum days, those got quite a bit more sophisticated. Both Inform 7 and TADS 3 would be able to handle landscapes that included highly-detailed urban spaces and less-detailed forest spaces, for instance.

Generally speaking, TADS 3 offers more pre-made world model features in its library — so for instance if you want your plans to involve detailed actions involving candles or flashlights or dark rooms, TADS 3 is more likely to have pre-existing implementations, and it can perform tasks like figuring out how sound or odor might propagate through a world space. On the other hand, Inform is designed to be pretty flexible about adding new concepts and relationships to its model world. Both systems have extension libraries by third parties that you could plug in as well.

I don’t know whether any of the implementations of this are up to date with the current versions of TADS and Inform, but Nate Cull wrote several implementations of Reactive Agent Planner, a library designed to allow NPCs to make plans about how to navigate text adventure environments — and re-plan in response to environmental changes caused by the player or other NPCs. I realize that you want to build your own planner, but this might be interesting to have a look at anyway.

Also in the IF space, Curveship has a pretty basic world model to start with, relative to Inform or (especially) TADS 3. On the other hand, it’s in Python (which might make it hook together better with whatever else you’re doing), and it provides a lot of options for how to present the narrative once the events of the story have been generated, such as the ability to tell the story from the perspective of one or another specific viewer.

Coding a large interactive environment in any of these languages is a fairly substantial task, and you would presumably also need to allow yourself time to get familiar with the coding expectations of each.

If you’re more interested in stories about people, social situations, and feelings, you might want a model that instead looked at modeling conversation or social practices between characters. Most of the social practice libraries I know of are proprietary rather than generally available (and some are quite quirky), but if you are interested in thinking about planning for social interaction stories, you might want to look at Versu, Prom Week, and Façade for pointers. Scealextric has a large body of paired actions and reactions, as well — in that case, devoid of any parameters about the physical requirements for a particular reaction.


Another place to look would be at academic story-generators after TALESPIN — of which there are many. Most of them are pretty much invisible in the IF world. This page on Story Generator Algorithms gives an overview. On a quick pass through I didn’t identify any obvious solutions for you here, but further research into the projects here might yield more.

(I do have a post on MEXICA upcoming later this month.)


And a couple of asides, mostly for other readers: another approach is to layer story interpretation on top of an existing simulation engine, allowing the engine to create a series of coherent events and then searching that space for event sequences that would qualify as an interesting story in some regard.

This is what Jacob Garbe does with his Dwarf Grandpa project, which takes Dwarf Fortress output and looks for ways to pull those simulated events into a coherent narrative. That post also talks about what Garbe calls “Recursive Narrative Scaffolding,” another story generation technique narratively linked to the tabletop RPG Microscope.

James Ryan has also worked in this space, building a simulator that creates hundreds of years of history that can then be mined for story events: this is the basis of his Bad News project (with Ben Samuel and Adam Summerville):

Beyond its novelty, Bad News is a deeply AI-driven game. Each Bad News town is procedurally generated using the Talk of the Town AI framework. Employing a method inspired by Dwarf Fortress‘s world-generation procedure, each town is simulated from its founding in 1839 up to the summer of 1979, when gameplay takes place. Over the course of this simulation, hundreds of generated town residents live out their lives, embedding themselves in rich social networks and forming subjective (often false) beliefs about the town. This provides an abundance of narrative material and dramatic intrigue—family feudslove trianglesstruggling businesses—that exceeds the capacities of a 45-minute playthrough and that could not have tractably been hand-authored. Several players have reported feeling like they were transported to the generated towns that they visited.

One thought on “Mailbag: World Simulation for Story Generation”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: