Text Adventure?!

You are standing in an open field west of a white house, with a boarded front door. 
There is a small mailbox here.
>open mailbox
Opening the mailbox reveals a small leaflet.
>read leaflet
(Taken)
"Welcome to my Senior Software Engineering Project!"

The Project

I have been assigned my project for the next three quarters, and it is a text based adventure engine. This project will require developing software that can make text adventures, and software that can play these games. The idea behind it is to create a platform for educators to easily create and distribute Text Adventure Games to their school computers.

Game Creator

This will be how educators create their interactive fiction. It has to be designed in order to be usable by people with low levels of tech familiarity (i.e. it can’t require programming or be a CLI). This system will then export the game as a large JSON file which contains all of the rooms, descriptions, puzzles, NPCs, inventory, and items.

{
    "Rooms":
    {
        "R1":
        {
            "Description":"A room with a couch and two chairs. There are two cats sleeping on the couch.",
            "NPCs":["Cat1","Cat2"],
            "InteractableObjects":["Couch"]
        }
    },
    "NPCs":
    {
        "Cat1":
        {
            "Name":"Pickle",
            "Description":"A soft siamese cat sleeping peacefully." 
        }
    }
}

Even writing this out made me start to realize how complicated the interconnections of a Text Adventure will be. I imagine we will have to standardize the interactions available for this project. I don’t believe we would have the time for developing customizable actions (look, drink etc.).

Game Player

This takes the game file an educator makes, and allows students to play through it. There are some interesting questions about whether game state should be stored in cookies in the browser, or if it should be stored server side. I lean towards saving game state server side, but I know that implementing that is more difficult. The advantages of being able to pick up where you left off on another device outweigh the difficulty in creating it. If I were to guess the best way to implement it, I’d say that after every action, the current game state would be updated from client to server. Upon restoring a session, the client would just pull the state from the server. This would also require account creation.

Text Adventures

Text adventures are one of the oldest forms of computer game, and are actually making somewhat of a comeback. You can go to itch.io and find many examples of modern interactive fiction. Traditionally text adventures are games delivered, you guessed it, entirely through text. Interaction with the game is done through typing in commands. This often involved focusing on verb noun pairs such as look bookcase or walk North. As text adventures got more complex, their input parsing did as well. The most well known text adventures are Zork I, and The Hitchhiker’s Guide to the Galaxy.

Zork Implementation Language

Zork Implementation Language was created to handle text command inputs from players. It is a rather robust system as far as text adventures go. I was able to find a manual that teaches you how to use ZIL. It divides command words into two categories, objects and routines. Objects can be rooms you stand in or even items, and routines are sub programs that perform various tasks.

ChatGPT

All of this parsing got me thinking about language models like chatGPT. It might be possible to make API calls to chatGPT in order to parse player input into actionable terms. I tested this with chatGPT and got pretty good results. Chatlog below.

Me:
I'm writing a text based adventure game. I want you to parse player input into actions that will be passed into my program. The program takes a verb, a object, and an indirect object. The indirect object is optional. Some example interpretations would be taking user input "hit the man with my bat" and returning "hit, man, bat". Another example would be taking the user input "look at the lake" and returning "look, lake". If you understand say yes

ChatGPT:
Yes

Me:
Player input: Look at the room

ChatGPT:
For the player input "Look at the room," the parsed action would be:

- Verb: Look
- Subject: room

So, the output would be: "Look, room"

Me:
Player input: eat the moldy bread

ChatGPT:
For the player input "eat the moldy bread," the parsed action would be:

- Verb: eat
- Subject: bread

So, the output would be: "eat, bread"

Me:
Player input: cut the bread with a knife

ChatGPT:
For the player input "cut the bread with a knife," the parsed action would be:

- Verb: cut
- Subject: bread
- Indirect Subject: knife

So, the output would be: "cut, bread, knife"

Me:
Player input: use my knife to cut the bread

ChatGPT:
For the player input "use my knife to cut the bread," the parsed action would be:

- Verb: use
- Subject: knife
- Indirect Subject: bread

So, the output would be: "use, knife, bread"

I checked the chatGPT api pricing and it seems pretty reasonable for our student project. I used GPT-3.5 Turbo for this example, and its pricing is as follows:

1000 tokens = ~750 words

ModelInputOutput
4K context$0.0015/1K tokens$0.002/1K tokens
16K context$0.003/1K tokens$0.004/1K tokens

Choose Your Own Adventure

These books are worth making a note of. Choose Your Own Adventure is another form of interactive fiction which is significantly more limited than text adventures. The interaction in CYOA is limited to the pages in the book. A typical page in a CYOA book would describe your current situation and then give you a few options based on choices you could make. The choices are limited to what the page presents you. Though this is more limited and less immersive, it makes both the creation of the stories, and the creation of the project much easier.

Existing Tools for Text Adventures

Because text adventures have been around for so long, there are quite a few ways to create them. I’m running out of steam in my research today, but will leave a small collection of what I’ve found so far so that I can review them next time. I hope to gain insight into how they work, and their user interface choices.
Twine
TextAdventures.co.uk which apparently uses Quest
Adrift
Inform

Print Friendly, PDF & Email

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *