29   Rafael Pérez y Pérez and the Problems of Creating Rounded Stories

As a scientist I want us to understand better the amazing thing we call creativity.

—Rafael Pérez y Pérez43

Rafael Pérez y Pérez is fascinated by creativity. When he was a boy, his family went on long car rides. His father would set difficult puzzles for him and his sister to solve. He encouraged them to ask questions. “‘Use your creativity,’ he always said,” Pérez y Pérez recalls.44 “Creativity has been on my mind since I was very young,” he adds.

His real love, however, was computers. For his undergraduate degree in Mexico, Pérez y Pérez studied electronics and computers. He went on to complete a PhD in AI at the University of Sussex. There he planned to work on AI and music but lacked sufficient musical knowledge. His PhD supervisor, Mike Sharples, was interested in the creative processes involved in writing. Sharples’s enthusiasm was infectious.

There have been several computer systems that generate stories, beginning in the 1970s. In 1999, when Pérez y Pérez was working on his thesis, and even sometimes today, plot generators worked in a typical AI manner: by problem solving. The operator chose a beginning to the story (initial state) and a conclusion (final state), then looked for a way to move from the initial to the final state by manipulating predefined structures, such as sentences and additional vocabulary. But that, thought Pérez y Pérez, is not the way creativity works. What he wanted was to explore human creativity, to create an algorithm that more closely reflects the way that storytellers create stories.

He called the algorithm he developed MEXICA (pronounced meh-SHE-kah), after the original inhabitants of his region, Mexico City, whom the Spanish dubbed the Aztecs. MEXICA produces plots inspired by the history, legends, and culture of the original Mexicas, featuring characters like jaguar knights, the greatest warriors of their day.

To use the MEXICA algorithm, Pérez y Pérez feeds in a set of short stories and a list of all possible actions that each character can carry out, plus a list of conditions for each action, represented in terms of the “emotional links, tensions, and conflicts between the characters. This is a unique part of my work,” he explains. “It mirrors the way that we come to understand the world.”45 In other words, it is the emotional links between the characters—the jaguar knight hates his enemy, for example—that create the preconditions and postconditions for the action.

Take a situation in which one character is in love with another. The man might

All these actions create an emotional response, especially if the woman is imprisoned. That creates conflict, she may start to hate the man. These consequences make up the story context. So the short stories build up the system’s knowledge base, into which Pérez y Pérez then inserts an initial action to trigger a particular story.

There are two elements in telling a story: engagement, putting together the plot, the bare bones of the story, and reflection, the many elements the storyteller adds to flesh the story out, bring it to life. In the engagement period, the system throws up plot ideas, “like when you’re dreaming,” says Pérez y Pérez. The reflection element modifies these ideas by filling in the gaps. Once Pérez y Pérez has entered the initial action to trigger a story, the system runs through its knowledge base looking for an appropriate structure to fit the new emotional context—the proper action to be performed. “If you input enough previous stories, you will have a lot of different contexts,” he explains.46 Then the MEXICA algorithm enters this information into a cycle of engagement and reflection. Driven by the emotional context, the story can develop in different ways.

In the scenario outlined earlier, the man in love has three possible courses of action: “beliefs of the system,” Pérez y Pérez calls them.47 Crucially, he is not generating his plots from templates. Actions spring from the emotional relations and conflicts of the characters. “If you could peer into the machine’s memory, you would not see short stories but the structures that represent emotional structures,” he says.

So far we only have plots. The next step is to turn them into stories. For this, Pérez y Pérez teamed up with Nick Montfort, a professor of digital media at MIT. “I sent Nick a story in the form character-action-character, and he took it and transformed it with his methods,” Pérez y Pérez explains.

Montfort calls his system nn Narrator. There is also a version called Curveship. It builds up a narrative using characters, objects, and events that have been fed into it. In this case, MEXICA provides the plot, characters, and events. Nn Narrator can change the order of events and narrate a story from the standpoints of different characters. Here is a portion of a narrative built up from a plot involving a hunter, a jaguar, and a virgin, adding a filter that expresses surprise:

The jaguar knight will oppose the hunter!

Meanwhile, the hunter will oppose the jaguar knight!

Then, the jaguar knight will feint at the hunter, dude!

Then, the jaguar knight will strike himself!48

There are clearly teething problems with this very early attempt at integrating two systems to form an automatic story generator that moves from plot to narration. A complex system like this requires different sorts of knowledge representation at varying levels of abstraction, as well as the ability to manipulate them appropriately to the story material. One way to do this is to use a “blackboard system” to keep and rewrite different versions of the story. Rewriting—editing—is a key element in storytelling as much as in the creation of a work of literature.

Soon after their initial collaboration, Pérez y Pérez and Montfort developed just such a blackboard system.49 They combined MEXICA and nn Narrator with three other systems to examine the plot generated and add action to it, rather like an assembly line. The blackboard was a “very easy way to communicate between systems.”50 They opened up the process to include metaphorical and other sorts of actions. First MEXICA generated a plot, which was then put on the blackboard. There it went through various cycles of engagement and reflection, including employing different genres, framing it as a “confession” told to a priest or, radically different, as a play-by-play sports commentary. Then Pérez y Pérez sent the end product to Montfort’s nn Narrator.

Here is a sports commentary version of a tale about Ehecatl, the Mexican wind god:

This is Ehecatl, live from the scene. The cold-wind eagle knight is despising the icy jaguar knight! The cold-wind jaguar knight is despising the chilling eagle knight! Yes, an eagle knight is fighting a jaguar knight!51

Perhaps a little more imaginative than the first story.

Pérez y Pérez and Montfort envisage this system supplying stories for exhibitions or being part of a digital media, electronic literature, or e-poetry exhibit and hope it will play an integral part in creating cutting-edge literature, though the production of an acceptable piece of narrative still seems a long way off.

At the end of 2017, Pérez y Pérez published a book of twenty short stories created by his MEXICA program. He called it MEXICA: 20 Years–20 Stories (20 AÑOS–20 HISTORIAS).52 The stories evoke the life of Aztec Mexico.

One begins, “Some years ago the princess was born under the protection of the great god Huitzilopochtli.” It’s still basically a plot, an outline rather than a fully fleshed-out narrative, but it brings in elements like a lady, a high priestess, a sacred knife, and the Quetzalcoatl temple, which together build a vivid picture of the Aztec world. The writing is noticeably smoother than in Pérez y Pérez’s earlier experiments:

The jaguar knight made a potion and drank it quickly. He started to recover.

In that moment the warrior was not able to understand the jaguar knight’s conduct.

The jaguar knight was confused and was not sure if what he had done was right.

Hurriedly, the warrior ran off to the Popocatépetl volcano.

The end.

Recently Pérez y Pérez has extended his MEXICA system to generate songs. He calls the new system MABLE.53 First MEXICA generates a plot about the Mexicas, then MABLE uses a Markov model that has been fed with a vast number of love songs to change each line into a poetic phrase. To do so, it takes one word at a time from the MEXICA plot, then searches through its database of songs and chooses a word that has a high probability of following it, taking into account rhyme and rhythm. Odd-numbered lines, starting with the first, are generated by MEXICA. Even-numbered lines are the lyrics that were statistically matched with it. Then Pérez y Pérez uses another algorithm (AKYSIA) to create a melody for the new poem. This produces several melody options for each line, which are curated by a musicologist au fait with computer science.

Maya Ackerman and Pérez y Pérez have recorded one of the resulting songs, “Princess Minuet,” on YouTube. It runs as follows:54

But she fell in love with him

Girl when they feel the same

The princess in love with the priest

Can’t let go and it never goes out

She also abominated what he did

Be the things they said

The princess was shocked by the priest’s actions

And though her heart can’t take it all happens

In this song both words and music were computer generated, unlike for the musical Beyond the Fence, in which musicians and writers played a large part in the curation.55 Listeners rated the experiment highly both in terms of plot coherence and emotional engagement.

As Pérez y Pérez says, this is a serious achievement for computational creativity, bringing “us one step closer to autonomous songwriters.”56

“My stories don’t read like Gabriel Garcia Marquez,” he says. “So what? Right now we are trying to understand this process better. You learn by degrees.”57 His ultimate goal, his Holy Grail, is “to contribute to the understanding of the creative process. As a scientist I want us to understand better the amazing thing we call creativity.”

Notes