PJ00 - Choose Your Own Adventure

In the first open-ended programming project, you will create a text-driven, “Choose Your Own Adventure” experience.

Your project will need to satisfy many specifications, so before you begin programming be sure to read this project’s write-up in full.

You are free to use your imagination to design and implement any experience you would like, as long as it meets the requirements. For some inspiration, here are some example ideas the UTA team and I came up with, if you are not feeling the spark of creativity:

  1. Taking care of a virtual pet like a tamagotchi. You are free to introduce additional variables, global or otherwise, for keeping track of a pet’s health.
  2. Some kind of role playing game where you choose what kinds of attacks or defenses to use and the opposing creature randomly chooses theirs. Points could be health or damage inflicted.
  3. A number guessing game such as the generating a random number and asking the user to guess it and counting the number of attempts it takes them to guess it correctly.
  4. A “buzzfeed quiz” that determines which Disney Princess character are (or anything else).
  5. A coinflip guessing game where you have to choose heads or tails and see how many you can guess in a row correctly.
  6. Some kind of mystery that involves searching a sequence of rooms.
  7. Something heavily emoji based, perhaps as surprising as a Japanese Game Show
  8. A parody of something that is poignant satire (a student once made a ConnectCarolina registration parody that was pure, comedic gold)

Again, feel encouraged to come up with an idea that is uniquely your own!

Background Lessons

The conceptual purpose of the game is to help you practice the concepts you have learned up to this point and explore some additional, related topics, including:

  1. String Escape Sequences (for Emoji!)
  2. String Interpolation (better than concatenation!)
  3. Named Constants
  4. Global Variables

As background preparation for this project, you should first complete the following lessons:

  1. Strings
  2. Scopes, Constants, Globals


These are the requirements for your project. Please read them in full and have a rough plan for how you will satisfy them all, before you begin working on your project:

  1. It must have a main function, that returns None, and follows the Python idiom for calling main at the end of the program based on the dunderscore variable __name__ being equal to "__main__".

  2. It should have a procedure, meaning a function that returns None, named greet. The greet function must print a welcome message to give some context to your game and asks the player for their name. The name given should be assigned to the global variable named player. You should call this procedure at the beginning of your main procedure.

  3. You should also establish a global variable named points to track “adventure points”. How you choose to use these adventure points is up to you. Initialize your global points variable from within your main function.

  4. After greeting the player, your main function should enter your experience. You should present the player with at least three options of where to go next and ask them to choose one. One of the three options should be to end the experience and print a goodbye message that includes the number of “adventure points” they accumulated in the experience. The other options should result in function calls which set the user off in different directions on the adventure. You will need to define appropriate functions for these distinct paths.

  5. One of the possible directions the player is set off in from main must be a procedure call. It should lead to textual interaction(s) that make use of players name and ask the player for additional input. The user’s decision should reassign the points global variable directly. At a minimum, increase the adventure’s points each time the player makes a choice. What happens within this procedure is up to you and you are free for this procedure call to lead to others, make use of loops, and so on. Get creative!

  6. One of the other possible directions the player can choose to set off in from main should be a call to a function that takes an integer as a parameter and returns an integer. Rather than accessing and assigning the global points variable, as you did in the previous procedure, the call to this function from main should pass the player’s points value as an argument to the function call. Like the previous procedure, you should make use of the player name in some output and have the user make at least one interaction choice that results in the points parameter (local variable) changing. Ultimately, this function should return the player’s total points after any interactions it leads to. Finally, the main function should use the returned value to update the global variable points.

Note: Requirements 4 and 5 are intentionally asking you to implement the same kinds of behavior but using two very different strategies in code for achieving them. The strategy in #4 relies on global variables shared between the main procedure and the function(s) you write. The strategy in #5 avoids the function(s) from directly accessing or reassigning the points global variable. There are trade-offs to each strategy. It is valuable to think through the trade-offs of both!

  1. You must make use of f-strings (formatted string literals) described in the strings lesson to produce any output that would otherwise require concatenation. No concatenation in this project!

  2. You are encouraged to make liberal use of Emoji throughout your adventure and required to use at least one Unicode character in your printed output or prompts. You must define at least one global NAMED_CONSTANT and assign it the unicode escape sequence "\U00000000" for each Emoji you use. Strings such as these are considered “magic numbers”, too!

  3. At least one path in your adventure must incorporate some element of randomness from the random library.

  4. 5 points of “above and beyond” are reserved for introducing a “game loop” in your main function. The game loop should allow the user to continue your experience and choose the same initial branch, or another branch, or to stop playing. Before looping, each time, you should update the user on their total number of points. We will cover loops on Tuesday 2/23.

  5. 5 points of “above and beyond” are reserved for going above and beyond these requirements by introducing additional adventuring functions or procedures your player can explore and interact with beyond the two required.

If you are attempting either or both of the “above and beyond” points, please describe what we should look for in your program per the instructions above in your top-level docstring. Remember, between the """’s docstrings can span multiple lines.

Getting Started

In your workspace’s projects directory, create a file named cyoa.py for this Choose Your Own Adventure experience.

Begin by defining a main procedure that serves as the “entrypoint” to the program. The initial call to main should be found at the end of your program, following Python’s idiom:

if __name__ == "__main__":


  • 15 Points - Static Type Checks
  • 15 Points - Linting
  • 5 points - main function allows user to choose one of three options
  • 10 Points - player and points global variables correctly declared
  • 10 Points - greet function meets specification #2 above
  • 10 Points - Procedure meeting specification #5 above
  • 10 Points - Function meeting specification #6 above
  • 5 Points - Used at least one emoji and setup a named constant for it
  • 5 Points - Used f-strings for building string outputs rather than concatenation
  • 5 Points - Incorporated randomness
  • 5 Points - Went above and beyond per specification #9
  • 5 Points - Went above and beyond per specification #10

Submission Instructions

To prepare your scene for submission, be sure to add a docstring to your module (at the top of the file) and a global __author__ variable set to a string which contains your 9-digit PID. Linting will also look for docstrings in your function definitions, per usual. 45 points of this assignment will be autograded, and the remaining 55 hand-granded.

Run python -m tools.submission projects/cyoa.py to build your submission zip for upload to Gradescope. Don’t forget to backup your work by creating a commit and pushing it to GitHub. For a reminder of this process, see the previous exercises.