Exercises in Generated Prose

What follows is an overview of some ways I7 can be used to generate more writerly prose, especially in the context of room descriptions. It refers to several extensions; of these, “Complex Listing” and “Plurality” are bundled with Inform and part of the standard distribution, but “Room Description Control“, “Tailored Room Description“, “Introductions“, “Assorted Text Generation“, and “Automated Drawers” are available from the I7 extensions site.

Structuring information to provide narrative focus

Sorting for importance:

The beginning and the end of any set (a list, a sentence, a paragraph) are the positions of emphasis, which means that we can use them to direct the player’s attention. Postponing information to the end of a grouping can also have a humorous or surprising effect, if that information is incongruous with the tone of what’s gone before.

“Complex Listing” exists to help with this at the low level, since it lets the author create a table and sort it on whatever ordering principles he wants, and also create delimiters however he wants.

“Room Description Control” sets the order of paragraphs in a room description. (“Room Description Control” expects to be used with a set of “writing a paragraph about” rules that specify the actual form of the output. “Tailored Room Description” is one such set.) Something similar is possible with the default implementation of looking in Inform using “locale priority”. The use of locale priorities is exemplified in the example “Priority Lab”.

Unless we’re going for a humorous effect, we probably want to avoid lists like

You can see here a broken goldfish bowl, a gold ingot, a crumpled Snickers wrapper, the King of Sweden (naked), a deck of playing cards, two used toothpicks, President Obama, a swirling transdimensional vortex, and a cotton swab.

…because this totally fails to capture the way that a person looking at the room would prioritize objects.

In general, it’s a good idea to rescue human and other sentient characters from this kind of list entirely by giving them unique “writing a paragraph about” rules that change to reflect their attitudes and behavior: this makes them seem more like people and less like pieces of the furniture. Likewise, the swirling transdimensional vortex is probably a sufficiently surprising sight to deserve its own sentence, at least.

Even with that done, though, we might want to arrange the list to put the good stuff (say, the gold ingot) at the beginning; and for this purpose one might use “Complex Listing” to mark all treasures, or all items currently valuable to a puzzle, or whatever, with scores that indicate their priority, and then sort accordingly.

The same technique can be used to invert the order and put key objects at the end, if we prefer to make them appear as a surprise:

You can see here a broken goldfish bowl, a crumpled Snickers wrapper, a deck of playing cards, two used toothpicks, a cotton swab, and a gold ingot.

Not punchy enough? We could emphasize that ingot if we wanted:

Before printing the name of the gold ingot while listing nondescript items:
say "fantastically valuable ".

which would give us

You can see here a broken goldfish bowl, a crumpled Snickers wrapper, a deck of playing cards, two used toothpicks, a cotton swab, and a fantastically valuable gold ingot.

Or we could underline the afterthought joke:

You can see a broken goldfish bowl, a deck of cards, a crumpled Snickers wrapper, a cotton swab and two used toothpicks here.

Oh! And also a gold ingot.

In the standard Inform implementation, this could be achieved as shown in the “Priority Lab” example; in “Tailored Room Description”, by tweaking the paragraph for description of “deeply dull” items to save this item for last.

Grouping: Items that are related to one another are often best presented as a group or set:

You can see here a pair of playing cards (the Jack and the Queen), a poker chip, and a five-dollar bill.

The “grouping together” activity provides a hook for this for use with the standard Inform listwriter. “Complex Listing”, by contrast, does not deal with grouping together, because this would be incompatible with the other options it offers for ordering the list of objects precisely; but an author could set the order of objects in the listing table in such a way that like items were clustered in the list.

In the larger context of room descriptions, “writing a paragraph about” is an excellent way to create pairs and grouping, as in

Jack, Flo, and Patricia are huddled in urgently whispered conversation at the foot of the patient’s bed.

The documentation on “writing a paragraph about” in the Activities chapter demonstrates this.

Picturesque effects: Sometimes when I’m going for a strong visual image, I want to structure my description to emphasize something other than the objects as objects: the lighting in the room, the sensation of clutter, an oppressive mood. The key here usually is to use a writing a paragraph rule to draw together descriptions of objects that might otherwise be described separately.

For instance, the example “Reflections” suggests a way to combine shiny objects into their own paragraph:

The radiant light of the fallen torch reflects in the surfaces of the reflecting ball and Aladdin’s lamp.

You can also see a piece of chalk, a plumbline, an abacus and a canopic jar here.

That’s as far as the example goes because it’s trying to demonstrate simply, but we could extend the idea to get rid of the “You can also see” line entirely, and replace it with a single cohesive paragraph:

The radiant light of the fallen torch reflects in the surfaces of the reflecting ball and Aladdin’s lamp. The rest of your equipment – the piece of chalk, the plumbline, the abacus and the canopic jar – is barely distinguishable against the surrounding shadow.

or, if there’s only one dull thing on the ground,

The radiant light of the fallen torch reflects in the surfaces of Aladdin’s lamp and the reflecting ball. The piece of chalk, by contrast, is barely distinguishable against the surrounding shadow.

We’d do that simply by extending our rule for writing a paragraph about a shiny thing to include the other, not-so-shiny things as well; once these are mentioned in the paragraph they will not appear again in the “You can see…” line.

Rhetorical and poetic effects

Good human-generated prose demonstrates a sense of musicality. It avoids repetition where repetition would be dull, but relies on parallel constructions for shape. It offers the reader natural places to pause. It changes tempo.

This kind of thing is very very hard to teach to a computer — it’s not always that easy to teach to humans — so what follows is just the set of things I’ve found worth doing and accessible.

Ordering for rhythm: ancient rhetoricians were interested in lists — how they were ordered for best effect, and how the elements in them were set off. A particular favorite was the tricolon crescendo, in which three items are named, each longer and more impressive than the last.

That particular flourish really only works if you know the list elements in advance, but some of the concept remains applicable even in generated prose. Clustering elements in pairs and trios rather than flat lists (“a mango and an orange, a plum and an apple and a brown Bosc pear, …”) can improve the rhythm of a long list and contribute to a sense of richness or abundance.

This is not always easy to design in a way that will sound good and is probably a technique to be used sparingly, but one way to achieve it would be to use “Complex Listing” and to change the “rule for delimiting a list” to operate differently under some circumstances. Bronze demonstrates another variation, using just the “writing a paragraph about” activity, in the section on the Black Gallery.

One could even, if appropriate, mark objects with information about the syllabic length of their names, or their phonetic qualities, and assemble listing sub-groups depending on alliteration or rhyme. But it’s hard to imagine a circumstance where that wouldn’t simply be distracting unless the work was overall written in a poetic register.

Listing with alternative delimiters: “Complex Listing” allows the author to build lists with alternative delimiters, as for instance

semicolons: “Rome; Venice; Paris; Lourdes.”
periods: “Rome. Venice. Paris. Lourdes.”
dashes: “Rome — Venice — Paris — Lourdes.”

Several settings are built-in, but the set can be extended freely.

Rhetoricians also used to talk about asyndeton and polysyndeton, the omission or over-supply of connectives. “Complex Listing” supplies these options as well:

Asyndeton: “Rome, Venice, Paris, Lourdes.” or “Rome Venice Paris Lourdes.”
Polysyndeton: “Rome and Venice and Paris and Lourdes.”

Changing list delimiters alters the pace at which the player reads. Semi-colons create stronger pauses in the reading, as is especially appropriate if the listed items are not merely names but longer phrases. Asyndeton and polysyndeton are best used sparingly; polysyndeton produces a sometimes-comical galloping effect when read aloud, while asyndeton can move quickly but bring the reader up short at the end of the list because it lacks the usual marker that the list is about to end.

Variation: avoiding repetitive sentence structures to increase a sense of greater liveliness in the prose, so that (for instance) not every supporter’s contents are introduced with the sentence “On the [foo] are…”.

“Tailored Room Description” does this by default: it picks randomly from a set of template sentences for common situations, and since these sentences are stored in tables, the tables can be amended or extended freely by the author.

Parallel construction: repetition of a structure for emphatic effect, perhaps also omitting some words that would otherwise be repeated. For instance,

The place is a shambles. On the pedestal are a fig and a cookie; on the table, a cup, a plate, an apple core and a vase; on the bed, a laptop and a camera; and as for the shelf, it supports a book and a toothpick.

Notice that we don’t repeat “are” in the clauses about the table and the bed, because the verb is held over from the first clause in the sequence. This is really another fairly cheap trick using the writing a paragraph about rules. With Inform’s default behavior, it could be written so:

Include Plurality by Emily Short.
Definition: a room is cluttered:
if it contains less than two supporters:
if every supporter supports at least two things:
Definition: a supporter is grounded if it is in the location.
Rule for writing a paragraph about a grounded supporter when the location is cluttered:
say "The place is a shambles. ";
let N be the number of grounded supporters;
let index be 0;
repeat with item running through grounded supporters:
increase index by 1;
if index is 1:
say "On [the item] [is-are a list of things on the item]; ";
otherwise if index is N:
say "and as for [the item], [it-they] supports [a list of things on the item]. ";
say "on [the item], [a list of things on the item]; ";
say "[paragraph break]".

The implementation for use with “Tailored Room Description” would be very similar, except that we’d want also to check that our supporters were “mentionable”, to make sure we weren’t referring to any that we wanted to keep concealed.

Structuring the text to show awareness of what the player already knows

Another key indicator of human-like narration is that the description contains as much information as the reader needs, but no extra information; and that it shows an awareness of what has already been revealed.

Choice of articles: using “a” or “the” correctly depending on whether we’ve already mentioned a given item during the course of that same description.

This is not too difficult assuming that we’ve been consistently tracking what has been mentioned so far during a room description. “Tailored Room Description” does this by default, and provides the phrase

To say (N - a thing) as a possibly-known item:
if N is mentioned, say "[the N]";
otherwise say "[a N]".

to be invoked when we want to be sure to use the appropriate article-state.

Concision: describing the stand-out characteristics of a scene only. For instance:

There are doors west, south, and east. The east door is closed.

This is more compact and idiomatic than

There are doors west, south, and east. The west and south doors are open. The east door is closed.

…but because of the rules of conversational implication it conveys the same information to a typical speaker of English. On the other hand, after the player has manipulated the room a bit, we might want to change to

There are doors west, south, and east. All three are closed.

Or again

There are doors west, south, and east. The west door is open.

The extension “Assorted Text Generation” supplies some tools for generating appropriate sentences of the “All three are closed” variety. It provides the (somewhat unwieldy) phrase “selection of (description) conforming to the description (a second description)”. This tells Inform to look at all the elements of the first set, count how many of those also belong to the second set, and print a descriptive phrase, which might come out to

“None of them is…”/”Neither of them is…”
“All three of them are…”
“The black door is…”

and so on, depending on what needs to be specified under the current state of the world model. We would still need to apply another layer of logic to decide whether we want to list the open doors or the closed ones, but ATG spares the work of hand-producing the subsidiary text.

“Automated Drawers” applies these rules to a rather specialized domain, namely, describing which drawers in a multi-drawer set are open. It generates text such as

The large dresser has five drawers. The top drawer and the fourth drawer are closed.

There are two tiny inlaid drawers in the table. The left drawer is open.

This may not be of much use in all instances, but it provides some sample code that might be used as a reference for other similar prose problems.

Introductions of objects: adding contextual information about objects when they’re first seen, or when the narrator/player character is inclined to point out a particular fact to the player.

The “Introductions” extension exists to help with this, allowing the author to define some introduction text to be printed as part of the room description the first time the player encounters a specific object.

First impressions for a room: Another common case is that we want to have a sentence (or a paragraph) of the viewpoint character’s first impressions of a room, to be printed at the end of the room description. The example “Saint Eligius” in the manual shows how to do this; “Introductions” offers an even easier implementation by allowing the author to create introduction text for rooms as well as for objects within a room.

Segues: moving naturally from the description of one item into the description of the next when both are present. E.g.:

Fred is no favorite with Doctor Pearson, either, which is why you’re surprised to see the old man sitting serenely in the comfy chair, sipping a vodka gimlet.

…to appear only when we’ve just described Fred’s presence in the room.

“Introductions” provides a mechanism for defining segues of this kind, using a look-up table for the two objects (the one described last and the one described next). This is especially likely to be relevant for independently moving characters, where the NPCs might be in any of a number of configurations when the player first stumbles on them.

Where the initial room description is static and the order is known to the author in advance, it would be enough simply to write this text into the initial appearance of the items, as in

The initial appearance of Doctor Pearson is "[one of]Fred is no favorite with Doctor Pearson, either, which is why you're surprised to see the old man[or]Doctor Pearson is[stopping] sitting serenely in the comfy chair, sipping a vodka gimlet."

Elaboration and discovery: Sometimes it’s worth going the other direction from the introduction technique, and have additional information that only appears when the player looks more than once (in order to streamline their first impression of a room) or to reveal information that the player has discovered in the course of play.

This is something to do carefully and sparingly, because a player who realizes he’s missing vital information in every room unless he types LOOK twice is likely to get really annoyed about it. Nonetheless, I did this with Floatpoint in some of the opening rooms, because I wanted the player to have a sense of urgency and movement, and only to see his surroundings in more detail (with which, in any case, he didn’t have to interact to win) if he deliberately stopped to explore. Several players reported enjoying the effect, so it seems to have worked in that case.

Omitting objects from the initial description can be done easily using the concealment rules with “Tailored Room Description”; or by the expedient of leaving some items out of play and moving them into the room after the first look. Bronze demonstrates a related effect with the Bellroom section, where specific bells become present as the player finds out about them.

12 thoughts on “Exercises in Generated Prose”

  1. Very nice! Thank you for the information; as a newbie to Inform, I always feel like I’m coming away with something I can use from your examples or essays.

  2. This was very interesting, but sometimes I feel like I know too much about the options available in Inform 7. It gets to the point that I start to feel overwhelmed when I think about trying to write a game myself. :) None of that is your fault of course, and I love that you write stuff like this to help people understand the potential of I7.

  3. The problem of automatically generating writerly prose has always been a major issue in IF. Thanks for your insights.

    It would be interesting to create Inform libraries out of resources such as the CMU Pronouncing Dictionary (http://www.speech.cs.cmu.edu/cgi-bin/cmudict) and see whether it could be used to automatically generate more poetic prose.

    PS: A pet peeve in “Listing with alternate delimiters”. I think you mean ‘alternative’. Alternate delimiters would be something like ‘Rome; Venice, Paris; Lourdes”

    1. PS: A pet peeve in “Listing with alternate delimiters”. I think you mean ‘alternative’. Alternate delimiters would be something like ‘Rome; Venice, Paris; Lourdes”

      I’d buy that for alternating, certainly, but in US usage “alternate” can mean “alternative” as well.

      However, I’ve made the tweak anyway.

      (In the unlikely even that anyone actually wants alternating delimiters, it wouldn’t be that hard to set up with Complex Listing plus text variations, with the delimiter text defined as “[one of];[or],[cycling]”…)

  4. “The King of Sweden (naked)”

    Great. I’m Swedish, and now I got this crazy image stuck in my head. This blog should come with a warning label attached to it or something. Good thing I’m a republican… ;)

  5. This is way nice, Emily. I really appreciate the time you took on this post, bringing together all this disparate stuff for tackling the sameness and occasional stiltedness of room descriptions.

    I don’t know how often others use an Instead Of Looking rule for purposes other than a static cutscene, but I seem to like them the more I write. (And this despite my programmerly advice to avoid Instead rules.) However, blending in the changes that gameplay has caused is a tedious chore. At one point I just tossed up my hands wondering aloud why I was spending so much time on the setting to begin with — it just wasn’t as important as the mass of rules surrounding it made it out to be. For that matter, a player’s oft usage of LOOK has more to do with game-state than setting, like it’s little more than a different kind of inventory listing.

    I guess more than anything I’m looking (har har) for an alternative (har) to room descriptions as the organizing principle of a work.

    So yeah, thanks for the primer on methods and reasons to declaratively express the state of a story in progress.

    1. I guess more than anything I’m looking (har har) for an alternative (har) to room descriptions as the organizing principle of a work.

      That’s possible too, depending on what you’re doing. I also have games that are primarily organized around scenes; room descriptions change in response to the specific plot stage, and there aren’t a lot of important portable objects anyway, so the player is encouraged to focus on conversation rather than double-checking the room status frequently.

  6. Ditto regarding my WIP’s lack of portable objects, but something just feels off when creating a scene-based or conversation-centric work. With room descriptions, there’s a text field to put the prose; a “place” in other words. This place is so important to Inform that the leading “The description of the budoir is” can frequently be omitted. But to attach prose to the beginning of a scene, you have to write a rule header and a say statement. That doesn’t sound like much of a difference, but considering I must also write a rule header and a say statement for that instance when my player tries to rub the unhappy snake on a distraught mongoose, it certainly seems like I’m already in the periphery of the programming language at word one of such a scene-based work.

    It would be nice if we could do, (with apologies to Austen for the hackery)…

    They met at the ball is a scene. “Elizabeth watched Jane leave with him, deciding to content herself by watching the dancers. After awhile, she noticed one well-dressed man standing curiously apart from the crowd…”

    …which would fill-in the “scene description” property that occurs when the scene begins. Or, something like….

    They met at the ball ends grouchily when Mr Darcy has left the building. “‘So that was the famous Mr Darcy,’ thought Elizabeth. ‘What a rude man.'”

    …filling in the endscene property.

    I don’t mind making explicit “When scene X begins” rules for oddball stuff, but showing some prose at a scene’s bookends seems to be important enough for the shorthand. That seemed to be the reasoning behind room descriptions getting the shorthand. So, again, the focus on room descriptions makes me… think grouchily.

    (And while I’m pining for a pony, scene-to-scene transition descriptions would be lovely, too:

    Commenting on Darcy’s rudeness begins when they met at the ball ends grouchily. “Elizabeth immediately sought out Charlotte. If Charlotte thought that that Darcy was not a nice fellow, well, then Elizabeth would surely know never to bother herself with the thought of him again.”


    1. And I just misspelled boudoir. *sigh*

      So yeah, a room’s prose is a noun, and that’s easy to latch onto. But a scene transition’s prose is.. some sort of action or verb, so I’m thinking of what’s going on rather than where I need to put the prose that needs to be said…

      I hope I make sense. It’s a hard feeling for me to articulate.

    2. I don’t mind making explicit “When scene X begins” rules for oddball stuff, but showing some prose at a scene’s bookends seems to be important enough for the shorthand. That seemed to be the reasoning behind room descriptions getting the shorthand. So, again, the focus on room descriptions makes me… think grouchily.

      Hm, interesting.

      I guess my assumption has always been that the beginning and ending of a scene will tend to be more complex than this by default: that there will be a need to move objects on and off-stage, to set variables, to otherwise mess with the world model. So a shorthand for setting scene-beginnings and scene-endings seems like it wouldn’t be useful much of the time — but maybe other people are finding they default to a different structure most of the time.

      On the other hand, maybe I’m just not thinking big enough, and what we need are not just scene-transition descriptions, but also some way to say “objects X, Y, and Z belong in scene foo”, and have them automatically moved to the location; or “scene foo occurs in…” and have the player’s location automatically reset.

      I also find myself frequently creating tables of atmospheric events for scenes, or tables of one-time events to move through.

      I don’t know how much of this Graham would find a plausible addition, but it might be worth more investigation, especially if you’re finding that the existing paradigm doesn’t support the kind of design you want to work on.

  7. Mmyeah I think I’m using them in a different paradigm that you have. I seem to recall someone (you?) mention the stage metaphor: at the end of most any scene, everything is moved off-stage, and the beginning of the new scene moves on-stage only what it needs. I haven’t been using scenes this way.

    First, I’m using the “Permission to Visit” extension for the verbs VISIT and ATTEND, which the player uses to decide who he’d like to spend the day with. (He’ll spend it primarily in conversation.) Think of P&P when a Bennett sister visits a friend or the Duchess: the visitation essentially uses the whole day, and the act of travel bookends the conversation, the scene, and the day. When you return home, your friends and their possessions stay at their home; there is no stage-clearing. The worldstate is changed almost exclusively by conversational actions.

    I think I’m using scenes more to provide contextual information for conversation, and to introduce a new plot complication when the worldstate says one now exists. I guess, in my paradigm, the cause-and-effect relationship between worldstate change and scene bookending runs in the opposite direction than yours.

    (While I currently needn’t the time-place-prop assertions you suggest, I seem to remember at least one other author on RAIF who was fond of the stage metaphor, and who would likely appreciate them. Assertions are likely easier to write & debug than rules, as they don’t play a shell game on your worldstate: assertions are “constants” and lend themselves to compiler scrutiny.)

    As I write more I may come into line with what you’ve done anyway, but, especially when sketching the work early in development, it would be darn nice to just “fill out the scenes” like many authors “fill out the room descriptions”.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: