October 28, 2013

A Gentle Introduction to Algorithmic Storytelling

How algorithmic and procedural thinking applies to narrative - the surprisingly generative relationship between systematic structure and creative story generation.

6 min read

Stories as Programs

Consider a story as a program: a sequence of instructions that, when run on a reader, produces a particular experience. The instructions are not executable in the computational sense, but they have structure - they specify a sequence, they take inputs (the reader's existing knowledge and emotional state), they produce outputs (new knowledge, altered emotional state, changed perspective).

This framing is not meant to be reductive. Stories are not merely programs. But the computational lens reveals structural properties that are otherwise hard to see - properties that can be used deliberately to make stories more effective.

The Grammar of Stories

Structural analysts from Propp to Lévi-Strauss to Greimas have identified recurring patterns in narrative - grammars that describe how stories work. Vladimir Propp's 31 functions, for example, show that most folk tales are variations on a small set of structural moves. The specific content varies enormously; the underlying structure does not.

This is the algorithmic character of narrative. Most stories are instantiations of a small number of deep structures, with specific elements substituted into structural slots. The romance follows the meeting-obstacle-resolution structure with particular characters and settings. The tragedy follows the rise-fatal-flaw-fall structure with particular virtues and errors.

Recognizing the structural pattern does not diminish the story - it reveals the generative grammar that the story is using.

Using Structure Generatively

The algorithmic lens is most useful when you are generating stories rather than analyzing them. If you know the structural slots that a story type requires, you can generate candidates for each slot rather than trying to invent the whole story at once.

The protagonist needs: a domain of competence, a want, a wound from the past, and a way that the want and the wound are connected. Each of these is a slot. For each slot, you can generate multiple candidates and test how they interact. The story emerges from the combination rather than being invented whole.

This is not how the best storytelling feels from the inside - it feels more like discovery than construction. But from the outside, and in retrospect, the structural pattern is usually visible. The algorithm was running; it was just running below conscious attention.

The Limits of Structure

Algorithmic storytelling has a specific failure mode: it produces technically correct stories that feel schematic. The structure is visible, the slots are filled, the beats arrive on schedule - but the story has no life, no particularity, no surprise.

The surprise in a good story comes from the specific choices made within the structural constraints, not from the structure itself. The algorithm provides the scaffold. The choices that make it feel real are the hard part, and they resist algorithmic description.

The synthesis is: use algorithmic thinking to establish the structure and generate candidates for each structural slot, then make the choices within that space with full attention to particularity and resonance. The algorithm is the scaffolding, not the building.

Narrative in Non-Fiction

The same tools apply, more modestly, to non-fiction writing - including the kind of analytical writing that does not think of itself as storytelling.

Most good analytical essays follow a structural pattern: establish a surprising or counter-intuitive claim, provide evidence and mechanism, address the objection, extend to implications. This is an algorithm. Knowing the algorithm makes it possible to run it deliberately, to check whether each structural function has been fulfilled, to see where the argument has structural gaps.

The insight is not that all writing is fiction. It is that structural awareness is as useful in argument as in narrative - and that the two are not as different as they seem.