Possible Extensions
There are a lot of possible and very fun extensions that you can persue with this project! Some options to get you started are included below, but ultimately you are limited only by your imagination (and time)!
- Better scenes with
history - Sometimes the scenes generated by ChatGPT can be a bit non-sensical, because the prompt doesn’t give the AI access to the entire history of all the things that have happened. In this extension, you could append a line to the prompt that is something like “Here is what has happened so far: <history>”, where <history> is a list of the scenes that the player has visited and the choices that they have made. Think of a way you could track this!
If you do this, use the “scene_summary” part of each scene when adding to your history of visited scenes. This will keep your history (and thus your prompt) from getting too large.
- Make your own creative story
- One way to go above and beyond is to just create your own story. You can write your own plot, your own scenes, and even create your own images if you want. Interested in an alternative history where President Thorsett’s weather machine always malfunctions? Make it! Want to write a story about a detective in the 1920s? Go for it! This is a great way to show off your creativity and storytelling skills, while practice authoring JSON.
- Open-ended actions
- What if the player wants to do something that is not in the list of choices? For example, what if the player wants to “jump in the stream” when the choices are “Take the road up the hill”, “Walk up to the stream”, and “Knock on the door”? How would you handle this situation? One option is to always give the user the option for an open-ended action, and then to use ChatGPT to generate a new scene based on the user’s input. This can be a challenging extension, but it is a terrific way to make your story more interactive.
To make the story still feel believable, you should also introduce a new dynamic where ChatGPT can decide if the open-ended action actually happens. For example, if the player enters in “fly to the moon”, ChatGPT could decide that this is impossible given the plot and other story elements. You could either make that action have no impact on the scene (the action just fails) or you could have ChatGPT generate a new scene for the failed action state! Get creative!
- Tracking Objects
- For this extension, you will need to think about how to keep track of objects in your story. For example, if the player picks up a key in one scene, you will want to remember that they have the key in the next scene. Could that key then be necessary to take some particular action? Would that action only be printed if the player has the key? This can be a challenging extension, but is an excellent way to make the interactions between scenes feel more dynamic.
- Displaying all scenes
- In the assignment specification, whene you encounter a scene with no image, you simply draw a black square. What if instead you rendered the text of the scene description? Or maybe just rendered a shortened version of the description? That would help the visual window still have some meaning even when no image exists.
-
Alternatively, if you are willing to register for your own OpenAI API key and invest the price of a cup of coffee, you could also make a call to OpenAI to render a new image from each scene description, which you could then save to the
imgfolder. An example of how the existing images were generated will be included in the starting template. - Saving Extension
-
Currently, if you play a story and generate a bunch of new scenes, and then exit the program and play the same story again, those generated scenes are all gone! So for this extension, it might make sense to think about how you could save the state of your story. You could save just the new scenes created by ChatGPT, or you could save the progress of the story as well! So that a player could run the program again to pick back up in a continuing story. Whenever you want to save a nested Python dictionary (or list) to a file, you can just
json.dumpto write the content to a file in JSON format. - Use your imagination!
- The joy of an extension is sometimes to think of something that nobody else is doing. Always feel free to implement something fun of your own devising!