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:
Again, feel encouraged to come up with an idea that is uniquely your own!
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:
As background preparation for this project, you should first complete the following lessons:
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:
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
It should have a procedure, meaning a function that returns
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
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
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.
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!
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
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
pointsglobal variable. There are trade-offs to each strategy. It is valuable to think through the trade-offs of both!
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!
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!
At least one path in your adventure must incorporate some element of randomness from the
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 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.
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__": main()
mainfunction allows user to choose one of three options
pointsglobal variables correctly declared
greetfunction meets specification #2 above
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.
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.