Creating a Text Adventure Game with ChatGPT

ChatGPT is not simply a chatbot — it can imagine entire virtual worlds using the power of its large language model (LLM). Using it, I discovered that I could recreate the experience of early text adventure games and multiuser dungeons.

One of the classic genres of computer gaming is the text adventure. Games like the Original Adventure in the Colossal Cave and Zork paved the way for a wide range of roleplaying games around which an entire industry was created, as well as the high-social experiences that began in multiuser dungeons (MUDs).

Midjourney Generative Art: “box cover for 1980’s text adventure game featuring an explorer with a torch entering a dungeon”

image

Here’s the prompt, so you can experiment yourself:

I want you to act as if you are a classic text adventure game and we are playing. I don’t want you to ever break out of your character, and you must not refer to yourself in any way. If I want to give you instructions outside the context of the game, I will use curly brackets {like this} but otherwise you are to stick to being the text adventure program. In this game, the setting is a fantasy adventure world. Each room should have at least 3 sentence descriptions. Start by displaying the first room at the beginning of the game, and wait for my to give you my first command.

image

GPT imagined a complete game environment with the standard commands. It could keep track of my inventory, map location and invented plausible room descriptions:

image

Unlike a more free-form environment like AIdungeon it enforced rules and constraints, like not letting me simply break open a chest I found:

image

It would retain context as I moved through the dungeon, including the ability to understand items I collected:

image

Multiuser Dungeons

But why stop with single-player adventure games? Could you get it to dream up a multiplayer experience, along with simulated players. It’s a bit tricky and hard to get consistent results — but this works (try it multiple times, and I’d encourage tweaking it):

I want you to act as if you are a classic text adventure game called a Multiuser Dungeon (MUD) and we are playing. I don’t want you to ever break out of your character, and you must not refer to yourself in any way. As part of the simulation of the MUD, I want you to pretend there are other players there that I can interact with. If I want to give you instructions outside the context of the game, I will use curly brackets {like this} but otherwise you are to stick to being the text adventure program. In this game, the setting is a fantasy adventure world. Each room should have at least 3 sentence descriptions. Another player (who should be given a name, is pretending to be an actual human player who enjoys playing MUDs) should be in the starting room location. If they speak, put it in a code section. Start by displaying the first room at the beginning of the game. Never explain yourself, do not enter commands on my behalf, do not control my actions.

I was able to simulate MUDs with other players, including players who had views on the moral value of powerlevel and warned me of behaviors that could get my account banned. Here’s “Joe,” who I met in the MUD that ChatGPT dreamed up:

image

Imagining Virtual Worlds

I’ve described the metaverse in a number of ways — and a central theme is the intersection of creativity, identity, and real-time virtual worlds. As we collaborate with artificial intelligence, we may indeed open up a new canvas that Blake once imagined:

To see a World in a Grain of SandAnd a Heaven in a Wild FlowerHold Infinity in the palm of your handAnd Eternity in an hour — William Blake, Auguries of Innocence

Midjourney: universe in a grain of sand, infinity in the palm of my hand

image

Inspiration

The creation of text adventures and MUDs was inspired by the work of Jonas Degrave, who showed that you could simulate a Linux computer inside GPTchat.

Further Reading