I want to expand on a topic Bill Maya mentioned in his last post on Inform 7.
But first a question – Why are real numbers and equations so important in storyworlds?
At their heart, storyworlds are simulations that model dramatic situations using real numbers assigned to character Attributes (real numbers are used because of the fidelity they provide). Frequently, two or more attributes are used in an equation to determine a character’s reaction to a situation
But this raises the question: why do numbers matter? Isn’t storytelling all about words and characters?
I feel this essay on interactive narrative design by Dan Fabulich provides a good summary of the argument, with a proposed solution. (This essay by Chris Crawford goes into more detail about some of the past failed attempts at interactive narrative structures.)
To summarize: combinatorial explosion absolutely limits any naive attempt to hand-craft responses to player actions in a branching web structure, even when limiting number of choices at each node to 2 (which is an extreme restriction from the player’s point of view). Foldback allows the author to offer more choices to the player at each point, by merging various threads back together at a junction point soon after. Variables let the author track choices made to some degree, so the player feels like their actions make a difference. The combination of these two methods is what allows for a wide spread of player choices and sufficient reactivity to same without collapsing under combinatorial explosion.
For a story to be compelling, it has to involve people: characters who take understandable, comprehensible (if not necessarily always nice, rational or well-thought-out!) dramatic actions in response to external situations and pressures and their internal goals and desires. A story full of no one but psychopaths, morons, and insane characters is not exactly conducive to great drama.
To be interactive, a story must be reactive (to player choice), which means the world state can conceivably reach a wide variety of configurations; and so for the characters to be able to take actions that meet the criteria expressed above, they need a certain amount of artificial intelligence.
Moods are a great example of a value worth tracking over time: they represent a summation of what has happened in the recent past (Bob is angrier if he has been threatened and yelled at recently, sadder if he has lost a friend), a given mood can be increased or decreased by many different events in various different orders (the happiness of receiving a compliment and the happiness of winning a game of sports may differ in magnitude, but are more or less the same thing, and effects of small events tend to accumulate), and they can provide clear motivations for actions provided they are expressed well to the player (more on that in a later essay). As with the “stats” in a Choice of Games work, it makes sense for these to be represented behind the scenes of the storyworld as number variables, for the fine granularity and flexibility this offers.
Another classic example is a reputation or opinion one character has of another. This can be considered something of a 2-dimensional extension of the concept of moods: where moods are reflexive, reputation is (mono)transitive. (The idea could be extended to two or even more objects — he knows she thinks he’s a slob, for a bitransitive example — but the memory requirements and conceptual complexity of more complex relationships quickly become astronomical.)
And how can you put these numbers to use in the course of a story? Well, a character can essentially only take one action at a time, so the AI boils down to selecting one of several options. Say there are 4 possible actions to take in response to a given situation: if each keys off of a different mood/opinion, and they all occupy the same scale, the easiest way to decide between them is to simply take whichever action whose related value is the largest. But as these values have been represented as numeric variables, they can be combined in more complex calculations as well.