Enter the maze

Dangerous Curves

by Pablo Gervás and Carlos León, Universidad Complutense de Madrid

Red Square at night: copyright istock.com 30478036

Russian tales, virtual worlds, dangerous curves...There are lots of sources of inspiration for programs that write stories! Pablo Gervas and Carlos Leon tell us about some of the ways their team at the Universidad Complutense de Madrid are exploring. How long before you are watching a Hollywood film where the storyline is credited to a program?

The shape of stories to come

One way to devise an algorithm to write new stories is to look at the structure of existing stories. People have studied literature for centuries, and have had some useful ideas about the shape stories take. Vladimir Propp studied Russian fairy tales and decided that they all fit a basic pattern: a Hero sets off on a journey to undo a wrong perpetrated by a Villain, they may be aided by a magical Helper, and they are rewarded at the end by marrying a Princess. Sound familiar? Based on Propp's ideas, our team have developed a program called Propper that can create stories by following this pattern. To make sure the stories make sense it knows about the things that must be true before particular actions can happen - a villain must have a sword if he is to stab a prince, for example. It also knows what the consequences of those actions are - that prince will be hurt if stabbed! Although Russian folk tales were used as the original inspiration, we're now adding more story structures. No doubt you can think of lots more. The detective who has to solve a crime committed by a murderer hiding in plain sight? The man in the street who saves the Earth from an alien invasion after the authorities fail? By extending Propper, and collecting enough patterns, we hope to build a reasonably good storyteller: one that can at least match the formulaic plots of your run-of-the-mill Hollywood movie!

Every story under the sun

Structure isn't the only way to produce a good story. When you play a video game the story changes based on what you do. Our team started with this idea as a way of creating stories. Our system, STellA, simulates a virtual world, just as video games do. In a virtual world lots of things can happen based on the rules of the world: characters eat, sleep, talk, have hobbies, and so on. As the world is simulated actions happen and a story unfolds. STellA is a bit different to a normal virtual world though. It generates all events and situations that could possibly happen within the limits of that world. It's as though a human writer worked out all possible storylines for their story: like Shakespeare writing out every feasible ending for Romeo and Juliet. While it isn't possible for a human writer, computers can do it in seconds. Why write one story when you can write them all!

The curve of a story

Unfortunately just generating lots of stories isn't good enough. One of the most studied problems in Computational Creativity is how to decide on the best result; the most creative work from those generated. STellA has to tackle this problem too: if you produce lots of simulations, you have to decide which one gives the story you want people to read. STellA deals with it in two ways. The first is to let the human who runs the program set conditions for the resulting story: they might require that the hero doesn't marry the princess at the end, for example.

The other way is to use curves! You pick some aspect of the story, like the amount of emotion involved or degree of danger, and represent it as a number. Suppose you chose danger. As the versions of the story progress the degree of danger in each changes in different ways and so the number representing it goes up and down in different ways too. Now think of that number changing as plotting a graph - the story is being modeled as a curve that goes up and down as the danger changes. A way to chose a story from the many possible ones simulated is to pick the one that best matches a given shape of curve. You might for example choose a story curve where the danger is high at the start, drops to nothing, then builds rapidly to the end. That would give a different story to one where its danger curve was always low. Based on its 'narrative' knowledge of the kind of curve that makes a good story, STellA can choose the best stories generated from its multiple world simulations.

Don't forget your readers!

Whichever way you write stories, it's important to remember they are written to be read by someone. Your stories will work better if when writing them you keep in mind what the reader is going to be thinking at each point. "Have I already told them that the old lady had a gun in her purse?" "If I say this now, will it give away the ending too soon?" Writers think about questions like that over and over as they write. They then rewrite their drafts based on the answer, adding, deleting or modifying things until the worries go away. Another line of research being followed by our team is to model this kind of behavior by writers so that we can use it to improve our whole family of storytelling programs.

Our model captures the way in which the writer (or program) working on a story does these things repeatedly: drafting, reading, asking questions about the draft, and redrafting until all their worries have been resolved. The story is then told or written down in its final version. Most existing storytelling programs (including ours) currently cover only a small part of the cycle that human writers follow. Once we extend them to include the missing operations, the stories they produce will improve massively.

Put all the different approaches together in one program and Hollywood watch out! What a story that will make!