This assignment was due in Moodle on Sunday, February 20 at 11:59PM. Click on the following file names to view the sample solutions: AdventuresOfTheMundane1.py and AdventuresOfTheMundane2.py.
For Assignment 2 you will write a very small text-only adventure game. This game is in the spirit of classics such as the Zork Trilogy which were released in the early 1980s and are still well-loved.
Description
The game puts you in the following hypothetical (and ridiculous) situation:
- You are facing the front door on the north side of your house; your backyard is to the south
- Your door is locked with a combination lock and you have forgotten the combination
- Your parrot can repeat the combination but you lost your parrot this morning when it flew into your backyard
- Your parrot is currently being menaced by the neighbour's cat; you must distract the cat to retrieve your parrot
- Your pet cow is grazing in the backyard watching the cat and parrot
It important to note that all games require you to suspend disbelief; this game is no different.
Winning the Game
You begin the game at the front door of your house. To open the door, you must perform the following actions:
- Go to your backyard (GO SOUTH)
- Milk the cow (MILK COW)
- Give the cat the milk to distract it (DISTRACT CAT); the parrot will fly to you and tell you the combination
- Go to your front door (GO NORTH)
- Enter the combination (TRY COMBINATION) correctly
Requirements
- You must use the contents of the file AdventuresOfTheMundane.py. It contains global constants for the commands and some of the text. It also contains two global variables haveMilk and haveParrot which record whether or not the user has milked the cow and retrieved the parrot, respectively. You are not permitted to define any other global variables and you may only alter the values of haveMilk and haveParrot.
- You must define at least four functions: one to manage all of the user's activities at the front door, one to manage all of the user's activities in the backyard, one to test the combination, and a main() function to run the program and move the user between the front door and the backyard when he or she enters GO NORTH or GO SOUTH.
- If the user enters a command that is valid but not allowed in his or her current location (e.g., MILK COW at the front door, GO SOUTH in the backyard) then the user must be told "You can not do that here".
- If the user enters a command that is not recognized at all, he or she must be told "I do not know what you mean".
- Commands must be recognized regardless of the case of the characters within (e.g., "go north", "GO NORTH", "Go NoRtH", "go NORTH", etc.).
- The user must be permitted to quit (QUIT) the game at any time.
- The user may always look (LOOK) at his or her surroundings; the situation described must capture the user's current location and what he or she has or has not accomplished thus far.
- The combination entered by the user must be compared against the list of numbers stored in global constant COMBINATION. The user must also be able to separate the numbers with any non-numeric character (e.g., "583714", "58/37 / 14", "58+++3714", etc., should all match list [5, 8, 3, 7, 1, 4]). The game ends if the combination is correct.
Click here to view example output from the sample solution.
Submission in Moodle
You may upload a single file named "AdventuresOfTheMundane<SECTION>.py". Please substitute your tutorial section letter for <SECTION> in the file name (e.g., AdventuresOfTheMundaneA.py).
Bonus
You may earn a bonus mark if you implement an "Easter egg". Change the game to detect a new command and print a witty response. You may declare one new global constant in this case.
Marking Scheme
Category |
Elements |
Marks |
Correctness |
No gameplay bugs
No Python errors which cause the program to crash
|
5 |
Requirements |
Use of all global constants
No other global variables defined
No global constants altered
At least four functions defined
Invalid or unknown commands managed gracefully
Command case ignored
Correct handling of LOOK and QUIT
Combination tested correctly
|
7 |
Style |
Appropriate comments
Good function and variable names
Appropriate separation of tasks into different functions
Values passed into functions as parameters where appropriate
Values returned from functions where appropriate
"Readable" code
|
3 |
Total |
15 |
Bonus |
1 |