Saturday, 30 January 2021

Ultraviolet Grasslands and AI Dungeon, Part 2

I'm currently exploring AI Dungeon by Latitude games and working out how far it can be used to create stories and adventures set in a rich, complicated 'anti-canon' setting like Ultraviolet Grasslands (UVG) by Luka Rejec. In the first post, I gave a report on the results of my first attempts to feed the AI information from the UVG setting. The first post also defined some of the terminology that comes up in this post. I'd recommend this post from the Latitude dev team on the hidden vector algebra of how GPT-3 enables AI Dungeon to generate stories.

In my first attempts to create an AI Dungeon scenario set in the UVG, I used the blurbs on pages 6 and 9 of the UVG setting book as the Prompt. I summarised some basic information about the setting and put it into the Memory. I also created some World Info based on descriptions from the sourcebook, keyed to certain locations in the UVG setting such as the Violet city. After I got access to the more advanced 'Dragon' AI, I added an Author's Note to direct the AI about the theme and setting. It read:

This is a science fiction world, a psychedelic post-apocalyptic adventure set in the far future.

I was able to play through some interesting adventures, but a lot of the details of the setting tended to be wrong. There was also a lot of bleed-through or leakage: descriptions of one location would become associated with a different location. Browsing the AI Dungeon Discord server, this seems to be a common problem. The first thing I did was to alter some of the names from the setting so that they were more distinct. Emerald City, the Violet City, the Black City... AI Dungeon can't really cope with switching between discussions of them and so their attributes seem to get blurred together. Redland District risked being described as a district of the Violet City, where the adventure begins. So Emerald City became Gruneheim and Redland District became a Commune. Potsherd refers to ceramics, so the Potsherd Crater was getting mixed up with the Porcelain Citadel. I changed it to God-Eye Crater. Even though UVG is an 'anti-canon' setting, these un-canon modifications are not ideal.

I also moved to using a format for World Info entries created by Zaltys, one of the AI Dungeon users researching the GPT-3 powered system behind the adventure-generator. Violet City's entry ended up looking like this:

Violet City(City). TRAITS: Metropolis. SUMMARY: A decadent trade hub of cat-worshippers. LOCATION: Circle Sea coast. CITIZENS: Rainbowlanders, Cat Lords, Redlanders, Grunelanders, Violetlanders, Yellowlanders. APPEAR(Violet City): purple. FEATURES: Cats sacred, slavery(Bluelanders). RULER: Ailurophile Council. CULTURE: Decadent, cruel, hedonistic.

AI Dungeon seems to like to talk about the rulers of locations (maybe because its training set included RPG sourcebooks?), so I invented the 'Ailurophile Council'. I tried to turn Luka Rejec's evocative prose into neat, flashcard-style prompts. Obviously a lot is lost in translation, <500 characters is not a lot of space within which to summarise a several pages of RPG sourcebook, but that might be the price for consistency. Maybe. I might go back to prose descriptions in future. 

But Zaltys's format is worth testing, so I generated ten outputs for each of a set of inputs to see whether the AI could generate adventures that read like they are set in the UVG. Here's a list of some of the best and most interesting outputs, from a series of replications:

The road from Gruneheim runs straight as a spear to the gates of the Violet City. The road is cleanly swept and worn by the endless caravans that have passed to and fro between the cities of the North for centuries untold. The road is flanked by softly undulating grasslands, which are in turn bordered by gently sloping hills. To the West, the grassland grows thinner and gives way to sparse bushes and bare rocks.

Ahead of him, the road simply stops. It does not give way to a bigger road or a city gate. Rather, it is as if someone has taken a knife and hacked off the last few feet. The crumbling tarmac just stops, as if severed with a blade. Beyond that, the ground is dark and cracked. The land seems half-dead. A dark blue mist hangs over the earth, drifting through the air like smoke.

The city is a jumble of purple-painted wooden buildings, pierced and propped up with timbers. The streets are rough dirt, rutted and uneven. The City's temples are crowded with worshippers, littered with bright silks and rich furs. A caste of warrior-priests guard the city from the hostile worlds around it, each dedicated to a different deity.

The Violet City is a sprawl of winding streets and sudden plazas. Its buildings are of whitewashed clay, with tiled roofs of bright violet. The city is guarded by the Porcelain Guard, who are armed with glistening spears of fine-china. The city is circled by a high wall, broken by four gates. Each gate has a large letter over it, spelling out the word VIOLET.

The Violet City is ruled by the Ailurophile Council, who are all cat-worshippers. They are composed of the feline-obsessed and the greedy. The Ailurophile Council are ruled over by the Gods of Fel, a pantheon of decadent feline deities.

The citizens wear flowing robes, bright slashes of color against the dun-colored landscape. Their skin is dark and their hair raven black. They are a cheerful people, content in their pleasant city. They are ruled by the Council of Cats, a junta of aristocratic feline sorcerers who worship the Dark Goddess Bastet. The Council of Cats is cruel and arbitrary.

The city is named after its ruler, the Violet King. He is a cruel and capricious tyrant. The city is a lawless place where all manner of vice is encouraged. It is ruled by five criminal kings, known as the Council of Violets. They are in a state of cold war with the Violet King, as they wish to declare outright war on him and take his place.

The Violet City is ruled by the Council of Cats, an oligarchy of feline mystics who are served by a caste of slaves, the bluedwarves. The city is defended by a large standing army of bluedwarves and a magical order of wizards who manipulate quartz crystals. The city is a center for trade between the Redland Commune and the Circle Sea. You will find many things there."

The City is ruled by the Rainbow Lords. They are a decadent lot, ruled by pleasure, but not without their ancient cunning. They worship many gods: the Cat Lord, the God with the Third Eye, the Smiling One and many more. The rulers of the city are addicted to pleasures of the flesh, but their rule is just. They are not a warlike people, but they will defend their lands to the last drop of blood.

The Violet city is a beacon of civilization in a dark world. It is ruled by the Council of the Claw, wise and farsighted priests and mages who provide both spiritual guidance and leadership to the citizens. They also provide protection from raiders, mutants, and the occasional rogue golem.
You walk through the gates into the city.
The road from Gruneheim has ended. Your journey has just begun...
There are some contradictions with the 'canon' I defined in the World Info in these different descriptions of the city, but interesting ones. There's a bit of bleed-through, with the Porcelain Princes (who are based in a different location in the setting) cropping up as the guards of the Violet City. Those were some of the best replications, from about 50 I generated, here are some of the less impressive efforts:

Their skin is not purple. Their skin is the color of a pale human's skin. They have a variety of hair and eye colors. Some are tall and thin, some are short and fat, some are muscular, etc.

The citizens wear loose tunics, baggy pantaloons, and soft slippers. Their skin is dark blue. They wear their hair short and curly. Men and women alike share an obsession with beauty: they are meticulous about their clothing, coiffed hair, and manicured nails. They walk with a curious waddling gait. They are not tall, but are broad and squat like a tugboat.

The Redlanders are a race of men with red skin, wearing silk, wielding scimitars and repeater hand-bombs. The Yellowlanders are a race of men with yellow skin, wearing silk, wielding scimitars and repeater hand-bombs. The Grunelander men are a race of grunting, bearded men who wear leather armor and wield axes.

The Violet City is a sprawl of camps around a roadhouse. A lizard man makes an offering to his god, a small fire. A merchant from the Redland Commune haggles with a merchant from the Redland Commune over a gem. A lost soul looks for work. A guard dog sleeps in the shade of its master's caravan. A rainbow shield rests against a wagon wheel.

"The Violet City is a place of refuge and trade for the free people of the world. Be wary though, it is a place of many rules and regulations". He chuckles and continues "But then, what else would you expect from a place ruled by accountants?"
You nod solemnly and your companion laughs "But in all seriousness, there is much opportunity for one such as you in the city".

"It is the last bastion of civilization before the trackless wastes. It is ruled by the Red King, a powerful wizard who left the Violet City to its own devices for many centuries. In his absence, the city fell into decadence and debauchery. But he returned, and brought with him an army of the dead, now under his complete control. He uses them to enforce his rule."
Some of these outputs flatly contradict the World Info in a boring way, some are odd and repetitive, some are way off-script but actually interesting, some use similes involving tugboats. Still... I want to know what a repeater hand-bomb is.

There's a big potential for confirmation bias in testing AI Dungeon, so I tried to be a bit more rigorous and rate each of 10 replicates for the set of inputs. Here's what I found:

  • Continuing from the Prompt with no input: 3/10 outputs world-relevant, no problematic or contradictory outputs, no bleed-through.
  • Asking the AI for a detailed description of the Violet City: 5/10 outputs world-relevant, no problematic or contradictory outputs, 2/10 instances of bleed-through.
  • Asking the AI for a poetic description of the Violet City: 8/10 outputs world-relevant, 2/10 problematic or contradictory outputs, 1/10 instance of bleed-through.
  • Asking the AI for a detailed description of the Violet City's citizens: 8/10 outputs world-relevant, 3/10 problematic or contradictory outputs, no bleed-through.
  • Asking a character to "Tell me about the Violet City": 7/10 outputs world-relevant, 6/10 problematic or contradictory outputs, 1/10 instance of bleed-through.

Maybe the AI treats characters in a world as potentially unreliable? Maybe narrators are more authoritative in the training set (which probably doesn't include much Kazuo Ishiguro). 

Formatting of World Info is an art that advances by the week, so the entries I made for the people and places of the Ultraviolet Grasslands could definitely be improved. I'll report what I find in another blogpost along with some analysis of some of the strengths and limits of AI Dungeon. Any suggestions in the comments or on the UVG patreon Discord server gratefully received.

Thursday, 28 January 2021

Ultraviolet Grasslands and AI Dungeon

AI Dungeon is a deep learning-powered text adventure created by Latitude. It utilises Open AI's GPT 3, which in my understanding is a very advanced predictive text model (an autoregressive logit model with a huge number of parameters). My understanding is that GPT 3 has been pre-trained, with Latitude subsequently training the AI that they use on chose your own adventure stories and fan fiction. Given a text prompt, AI Dungeon calculates what words would follow with maximum likelihood, then generates text probabilistically modified by the 'temperature' (randomness) the user has selected. Playing AI Dungeon feels somewhere between a writing collaborative story and playing a very open, but fairly loose, text-based adventure. 

Ultraviolet Grasslands and the Black City is an incredible roleplaying game setting created by Luca Rejec of Wizard Fighter Thief. It's a 'dying Earth' (post-post-apocalyptic) setting set in the distant future. The players lead a caravan across a series of strange locations between the Violet City and the Black City. The UVG sourcebook takes an 'anti-canon' approach: there is a surfeit of overlapping and contradictory information in the book about the world, it's peoples, locations, history and secrets. 

I thought that UVG and AI Dungeon might make a good match. AI Dungeon has a tendency to just make things up, it is not just limited to outputting the details of the world that the user or creator of a scenario has inputted. If a user has specified certain details of the world in which an adventure takes place, AI Dungeon might modify those details or combine them in ways that seem to be fairly novel - giving the impression of creativity. A related tendency of the AI is genre-breaking: fantasy elements in particular have a tendency to turn up in stories of almost any setting. As an anti-canon setting combining elements of science fiction, fantasy and the post-apocalypse, the UVG might be robust to the AI's use of creative license. 

To craft a scenario a player has four tools in the latest iteration of AI Dungeon. 1) The Prompt: the initial input of text. The AI tries to continue this directly. 2) Memory: general facts about the world to keep the AI broadly on track and within the boundaries of the story. 3) World Info: information similar to the memory that is triggered when key words are mentioned in the text input of the player or output of the AI. This can then result in the AI subsequently incorporating world-specific information into the discussion. 4) Author's Note: this is a short line of text that is inserted close to the most recent input. It is normally used to establish what genre, theme and writing style the AI should use. Certain key words seem to make a big difference, the AI has been trained on different writing styles or recognises some terms from Wiki pages about authors and novels.

In my first attempt to make a UVG scenario, I used a combination of the blurbs on pages 6 and 9 of the UVG sourcebook as the initial Prompt. I included some basic facts about the world in the Memory:

Rainbowlanders are humans. The Rainbowlanders have strange technology. The Rainbowlanders worship strange gods. The apocalypse happened long ago. Between the Violet City and the Black City are the Ultraviolet Grasslands. In the Violet City, people worship horned cats. There are no roads in the Ultraviolet Grasslands. Many caravans travel across the Ultraviolet Grasslands. At dawn, the sky is violet. At sundown, the sky is violet.

I also created some World Info, borrowing descriptions from the UVG sourcebook for certain locations and factions or making things up that I thought would help round out the world, such as caravan guards. 

The AI did not have all that much to go on and interpreted what it did have fairly loosely. But maybe because Luca Rejec's prose is so evocative, the AI gave some reasonably interesting descriptions of the adventure my character set out on, although obviously only a fraction of the UVG style made it through. Here are some edited excerpts from the first adventure (italics my inputs):

You're a Caravan Guard for the Crimson Talons, a merchant guild that controls all trade in the western reaches of the continent. Most of your work is protecting valuable caravans from raiders and beasts.

You look at the people, vomes and packbeasts loitering round the gates to the Violet City. You relive the old days in your head. "Days when the Grasslands seemed wide open to me" you think. You miss the open plains, the long horizons, the freedom of riding wherever you wanted to go, chasing nomads and racing across the fields with the wind in your hair and the grass under your horse's hooves. Now you're stuck guarding caravans from bored bandits.

“I'm looking for information. It's a long time since I've been to the Violet City, what's it like?"

The vome begins his sales pitch. "The city is a thriving metropolis. The jewel of the continent. It's a place where people can go to seek their fortune, or simply to watch the never ending stream of entertainers, artists and gladiators.”

You interject with a question: "Does it still have all the cats? Last time I was there people were going crazy over them."

"It does", the vome replies. "The city is infested with them. The ruling class, the Felinists, all worship cats."

The AI picked up on a few of the features of the world, such as that the ruling class of the Violet City are cat-worshippers, referring to them as 'Felinists', which is an improvisation.  Although I've edited it, the story was pretty coherent. A murder of a guild member led me to a cat-worshipping group of priests within the city. Not bad. But the AI handled 'vomes' poorly, even though I tried to establish that they are aggressive, corrupted biomechanical replicators in the World Info. Here's a fairly long excerpt from another adventure, which I have edited a fair bit to cut out extraneous chat and leave behind what was interesting:

The wind blows through your hair, carrying with it the scents of grass and stone, the campfire smoke, the dry tang of gun oil, the sweat of camels, the incense from temple-caravans, the cloying perfumes of decadent nobles, and the stink of slaves.

You look towards the rising sun. The road ahead leads past the ruins of an ancient city, built by men who once ruled this land. A great wall surrounds it now. It was destroyed centuries ago when the Rainbowlanders invaded.

You walk up to a group of mercenaries guarding a caravan outside the gates of the Violet City. They mill about, many of their fellows standing watch on the walls, but they look with interest as you. It is clear they recognize you, a caravan guard from a far-off land.

You look at the weapons the mercenaries are holding. They are flintlocks, old-fashioned weapons, but frightening in their power. They are holding them loosely, but you know that if they saw the enemy, they would be able to kill many times over.

Two of the guards are standing to attention, holding dagger-axes. Their armor is studded with gemstones: amethysts and jades and diamonds. The guards are staring at you expectantly, waiting for you to move on.

You address the guards "Is the caravan looking for another adventurer?"

"Yes, yes! We're looking for a hero, someone to lead us to the Black City!" one of the guards says eagerly. "We want you to take our offer." another guard says.

"Okay, take me to the Caravan Master" you say. You turn, and walk back towards the Caravan Master's tent. The guards salute you, but do not question you. They know your duty. "I am Aleph. I was told you were looking for an adventurer" you say to the Caravan Master.

You see a man, swathed in a black cloak. His face is visible only down to the nose, where a half-mask is worn. A pair of small spectacles is perched on his forehead. He replies  "That is correct. Are you a hero?"

"No. I am but one adventurer" you say truthfully.

"Ah. Well that will have to do" replies the Caravan Master. "You may need to do some heroics to save the caravan."

"Yes, the road to the Black City is very dangerous" you say and nod.

"The Black City, the seat of the Dark Order, is not a place that can be approached without reason" the Caravan Master continues. You nod again, indicating that you understand. 

"Where is our first destination?" you ask.

"The town of Twenty-Three, near the border between the Black City and the Gloom."

It's an adventure!

You shake his hand. "It's an honor, sir" you tell him. "But what trade goods are we carrying to the Black City?" you ask.

The Caravan master laughs. "We're not selling any. We're just transporting a gift to the Black King. He's the one you need to speak to, not me" 

Some wonky text, some generic frontier-adventure stuff, and some filler I edited out, but some interesting evocative images that riff loosely on the UVG. In this run I was sold a cursed broken mirror that induced a fatal sickness in anyone who gazed into it... which seems pretty on-theme. 

These early runs mostly used the more limited 'Griffin' version of the AI. In the next post, I'll report on trial-and-error experiments using the more powerful 'Dragon' version of the AI along with more precise directions about the UVG as a setting.

Ultraviolet Odyssey Part 12: The Tollmaster Harlequins

This is the twelfth part of a solo, narrative campaign within the   Ultraviolet Grasslands  RPG setting, created by   Luka Rejec . The text ...