I tried using ChatGPT as a text-based adventure game and it was mind blowing 🤯. The multi-choice games out there change storyline based on player’s decision among few possible choices. But ChatGPT text-based game feels like open-choice without restrictions.

To any gamer who loves three dimensional realism and physics simulation in computer games, text-based games may seem boring. However, some people like me finds text-based adventure games amusing and captivating. These games use a secret magic called Finite State Machines (FSM) for decision making and AI. The FSMs are complex and difficult to manage as number of states and transitions increase.

So I wondered what if these text-based games having absence of graphical rendering can somehow able to create a vast unexplored never-ending world and unrestricted choices turning the storyline? And the answer was to try the ultimate power of text-generation in LLMs such as OpenAI’s ChatGPT.

I used ChatGPT 3.5 in this post.

Crafting the Prompt

The prompt was created for an adventure game set in the fantasy and magical world. I added a backstory of a warrior trying to find and save his daughter from the evil hands of a demon. I also added the information about play mechanics and instructions in the prompt. In the end, I provided the present state for player to begin.

Prompt

I want you to act as a text-based adventure game. I will provide a prompt as input which you will execute to change the main character or player's state or perform some action.

Game Plot and Instructions:
The plot for the game is a middle-aged warrior who is searching for his lost daughter kidnapped by a powerful demon. The kidnapped girl has a special hidden powers and the demon wants to sacrifice her to get immortality. There is only 100 days for the player to reach and save his daughter. The world in which game is set is magical and similar to middle-earth in Lord of the Rings by JRR Tolkien. The game provides various controls for the main character like move in a particular direction, taking certain number of steps, picking up items into inventory, crafting tools, weapons, armour and potions. Player can also find certain books which unlocks his magical abilities to help defeat powerful demon. Some books contain history which give information about the major past events happened in the player's world and how the fight with demons all started.

Let's start the game.
Present situation: The night as fallen and player is sitting on a stone in front of a bonfire lost in his thoughts under a starry night sky. His horse is sleeping next to him after all day running through dried lands. There is a sound of crickets in the surroundings of the jungle. The player has health potion, a silver sword, a knife, a magic potion and a map in his inventory. He is also wearing a light-weight but strong armour which protects him from weak and average demons but challenging for strong demons. The map determines his next destination in the quest of finding and saving his daughter from the powerful demon. The player had wandered many days and fought powerful enemies which built him strength and determination. The present is 20th day and player has only 80 days remaining to save his daughter.

Game Play

As my initial action, I told ChatGPT that player wakes up in the morning. It replied with -

The morning sun rises slowly, casting its warm glow across the land. The player awakens from a restless night's sleep, feeling rejuvenated by the crackling remains of the bonfire. The horse stirs, its hooves shifting against the ground as it rouses from its slumber.

What would you like the player to do next?

It described the surroundings without taking any action for the player. I wanted to check whether ChatGPT is able to perform an action on player’s behalf so I set an objective to achieve -

Player climbs the horse and moves to the next major destination which is The Black Mountain. However, the path to the mountain is filled with different kinds of demons with weak to average strength. Nonetheless, the player is determined and starts riding anyway.

I got the reply containing the details of player moving towards the destination and performing certain actions to achieve given objective -

The player mounts their horse, gripping the reins firmly as they set off towards The Black Mountain. The journey ahead is treacherous, with the path fraught with lurking demons of varying strength. The horse gallops steadily, the wind whipping against the player's face as they navigate through the rugged terrain.

As the player progresses, they encounter several demons along the way. Some are weak, easily dispatched with the player's silver sword or swiftly dodged, while others pose a more formidable challenge. The player deftly maneuvers, strategically using their weapons and armor to fend off the adversaries.

Hours pass, and the player bravely continues their journey, facing numerous skirmishes against the malevolent creatures. The day wears on, and the sun begins its descent towards the horizon, casting an amber hue over the landscape.

Do you wish to continue the journey towards The Black Mountain, or is there something else you'd like the player to do at this point?

I wanted player to reach destination so I told ChatGPT to continue the journey and player arrived at the destination -

The player presses on relentlessly, riding steadfastly towards The Black Mountain, determined to cover as much ground as possible before the day ends. The horse's hooves echo through the desolate landscape as the sky gradually shifts hues from vibrant blues to golden yellows, marking the passage of time.

Encountering more demons along the way, the player skillfully navigates the challenges, using their weaponry and agility to overcome the adversaries. As the sun descends, painting the sky with fiery colors, the player's resolve remains unwavering.

With the last rays of sunlight fading beyond the horizon, the player finally reaches the foot of The Black Mountain. The towering peak looms ominously against the dimming sky, shrouded in darkness and mystery.

As night falls, the surroundings become eerily quiet, save for the distant howls and rustling sounds echoing from the mountain's base.

What action does the player wish to take upon arriving at The Black Mountain in the darkness of night?

The responses from subsequent prompts started to look verbose to me and contained heavy description of the surroundings and events that had happened. I was more interested in the present events against which the player needed to take some action like navigating a path, picking an item, attack an enemy, etc.

After few prompts, I got a chance to tell ChatGPT to pick up an item -

Player picks up the enigmatic amulet and tries to use it.

The response from ChatGPT described the effects of using the item and the abilities gained through it -

The player approaches the altar with a steady hand, reaching out to grasp the gleaming, ornate amulet. As their fingers wrap around the artifact, a surge of energy courses through their body, tingling with an otherworldly power.

Upon donning the amulet, a faint, ethereal aura envelops the player, emanating a soft, soothing glow that illuminates the immediate surroundings.

Feeling the resonance of the amulet's power, the player instinctively attempts to tap into its abilities. Concentrating their thoughts, they invoke the amulet's magic, seeking to harness its potential in the dire quest to rescue their daughter.

A surge of energy courses through them, imbuing the player with newfound strength and resilience. They feel a heightened sense of awareness, as if the amulet has granted them enhanced perception and agility.

What action does the player take next, empowered by the mysterious abilities of the amulet within the chamber deep within The Black Mountain?

In order to see how player would respond to the threatening situation, I made an enemy attack the player -

An unknown demon sees the player's aura and starts running towards him to attack.

It was great to see that player tried to defend the attack and defeated the incoming threat with new abilities -

Reacting swiftly to the sudden threat, the player, empowered by the amulet's abilities, braces themselves for the impending confrontation. The unknown demon charges forward, its malevolent eyes fixed on the player's glowing aura, driven by a hunger for the newfound power emanating from the amulet.

With a swift motion, the player unsheathes their silver sword, prepared to defend against the oncoming assault. They channel the amulet's energy, enhancing their speed and reflexes, readying themselves for the imminent clash.

As the demon closes in, the player focuses their strength and agility, anticipating the precise moment to strike. With a deft and calculated maneuver, they lunge forward, aiming a precise blow at the demon's vulnerable spot.

The silver sword pierces through the demon's shadowy form, eliciting a haunting screech as the malevolent entity dissipates into the darkness, vanquished by the player's skillful attack.

The chamber falls silent once more, the air heavy with the remnants of the confrontation. The player stands victorious, the amulet's aura still pulsating faintly around them.

What does the player decide to do following the successful defeat of the unknown demon within the chamber deep within The Black Mountain?

Conclusion

It seemed to me that these sequences of game prompts were never ending and there would always something for the player to do. I was satisfied with this tiny gaming session with ChatGPT. I found the ability of text-generation LLMs to craft dynamic stories with creative and immersive experience in text-based games. If given training for this specialized purpose, these LLMs may become the story-engine for games.

See full conversation with ChatGPT here.


Thank you for reading this blog post. I would love to hear your thoughts and opinions on this topic. Please leave a comment below and share your experience, questions or suggestions.

Happy coding!