ChatGPT just wrote a game

by | Apr 30, 2023 | ChatGPT 4, Human / AI, Learning, MidJourney

No, that’s not hyperbole – ChatGPT literally just wrote a game. Tasked with the following prompt:

I would like to create a “choose your own adventure” type game in Javascript. I would like the interface to be text based, with the layout looking like this [Layout drawn in ASCII]:

Monospace representation of the prompt provided to ChatGPT

The ChatGPT interface doesn’t represent ASCII well, but rest assured, ChatGPT understands it just fine.

ChatGPT then proceeded to prove its ability to generate code by rapidly (even for GPT-4) outputting HTML, CSS, and JavaScript to create a fully functional prototype for a game. While the game at this point lacks a compelling storyline, it is completely playable, demonstrating ChatGPT’s ability to generate useable code. All that was required was two minor CSS tweaks to ensure accurate rendering in the intended viewport (a restriction that GPT was not made aware of), and removal of the links to CSS and JS as the content was loaded into JSFiddle. Then, for better display – again, a restriction that the AI was not initially made aware of – GPT was asked to modify the code for responsiveness. The speed that ChatGPT developed this game is not only remarkable for its playability from the outset, but is also a testament to its potential for software and application development.

Version 0.1 “Javascript Adventure Game”

Honestly, this is beyond remarkable. It’s astounding.

Version 1.0 “Dragon’s Dilemma”

Having already exceeded expectations with the code and basic story, it was time to see if ChatGPT could write something a bit more interesting. Politeness, somewhat unsurprisingly on a system trained on human-generated content, tends to output better responses, so the following prompt was provided:

Thank you very much!

Now, i would like to actually work on the story.

You’ve done a great job with the boilerplate story, but we can get something really awesome. Will you please replace the story constant with a new story? Please feel free to be as loquacious as possible and make the story compelling.

Again, ChatGPT immediately demonstrated its ability to generate fully functional content with remarkable speed and efficiency. Only a single “Please Continue” was required to get the complete output, ready to be inserted into the existing codebase. This is a testament to ChatGPT’s ability to produce high-quality output with minimal input. The efficiency and accuracy of ChatGPT’s output shows its potential as an invaluable tool for developers and content creators seeking to streamline their workflow to save time and resources.

The Box Art

No text-based game from the 80’s would be complete without wickedly illustrated box art. ChatGPT was prompted:

Great! Can you please describe what the box art would look like if this was a floppy disk game from the 80’s?

Certainly! If “Dragon’s Dilemma” were an ’80s floppy disk game, the box art would be a vivid, hand-drawn illustration with a slightly exaggerated and adventurous aesthetic, reminiscent of the fantasy art of that era.

In the foreground, our brave hero stands clad in armor, wielding a shining sword and a shield emblazoned with a crest. The hero’s expression is determined, and their eyes are locked on the challenge ahead.

The middle ground would showcase the quaint village, with its thatched-roof cottages and bustling villagers. The villagers are looking towards the hero with expressions of hope and admiration. A mix of lush greenery and dense woods surrounds the village, creating an idyllic atmosphere.

In the background, the imposing Stony Mountain looms over the scene, with its rocky and forested paths leading up to the dragon’s lair. The lair, a dark and foreboding cave entrance, is shrouded in shadow.

The fearsome dragon, the central figure of the box art, is illustrated with vibrant colors and intricate detailing. It has large, outstretched wings, sharp claws, and piercing eyes. A plume of smoke and flame billows from its mouth, emphasizing its immense power and the danger it presents.

At the top of the box art, the game’s title, “Dragon’s Dilemma,” is written in an ornate, fantasy-style font with metallic textures and a subtle drop shadow. The overall color palette is rich and high-contrast, with deep shadows and bright highlights, adding to the sense of drama and adventure.

This box art would evoke a sense of wonder, danger, and excitement, inviting players to immerse themselves in the world of “Dragon’s Dilemma” and embark on a thrilling adventure to confront the fearsome dragon.

The intent of this prompt was to turn around and feed it to MidJourney. Over-complex MidJourney prompts can lead to hallucinations or strange artifacts, so this response was considerably more detailed than expected. But feeding the above prompt from ChatGPT into MidJourney spit out these exceptional results:

To complete the project, ChatGPT was asked to “Please select one ‘scene’ from your game and describe it visually, but succinctly, as if for an image-generation AI.” to which it replied:

A heroic adventurer stands at the base of a winding, forested path on Stony Mountain, gripping a shining sword and a shield, gazing upwards at the dark cave entrance shrouded in mist, where the fearsome dragon resides.

MidJourney’s interpretation of ChatGPT’s description of a scene from the game.

In Conclusion

ChatGPT created a fully functional “choose your own adventure” game with exceptionally minimal input, generating HTML, CSS, and JS code that required no modifications to run on it’s own. Upon further instruction, it enhanced the story, creating a more compelling narrative, and recalled enough of the existing context to do so without assistance. Finally, ChatGPT was asked to describe the box art and a scene from the game it wrote, and MidJourney produced visual content exceptionally well. ChatGPT’s ability to rapidly produce high-quality content demonstrates its immense potential for software and application development. Remarkably, all of this was accomplished within the 25 prompts in 3 hours limit of ChatGPT-4, demonstrating it’s usefulness as a tool for developers and content creators aiming to streamline their workflow, save time and resources, and enhance their abilities and content. MidJourney demonstrated it’s usefulness for studies, creative development, and rapid creative prototyping.

For the full transcript of the conversation with ChatGPT, see this Gist:

https://gist.github.com/avanrossum/7c00c4006896bfc3e0c4bcc35f710882

Related Posts >

Mastering Prompt Engineering Techniques

Mastering Prompt Engineering Techniques

Mastering the art of prompt engineering is vital for making the best use of the tools available today, and will build a strong foundation for the increasingly powerful systems that will be available in the near future. By building experience in the areas of prompt phrasing, step-by-step guidance, incorporating examples, and experimentation, users can significantly enhance the quality of their interactions with these new AI systems.

read more
Understanding Prompt Engineering and Its Importance

Understanding Prompt Engineering and Its Importance

Prompt Engineering is the process of meticulously designing and refining prompts for AI models, such as ChatGPT, MidJourney, and Stable Diffusion, with the objective of achieving a specific, desired outcome. A proficient Prompt Engineer crafts input questions, queries, guidance, or statements that enable AI systems to better comprehend the Engineer’s intentions and generate accurate and valuable results.

read more