Project 1
Due: October 6, 2023 by 10:59pm
Submitting your project
For this project, you must hand in just one file:
- gamify.py
You can resubmit a new version of the file at any time before the deadline. Your last submission will
be graded.
The if __name __== __"main"__
block
All your testing code should be inside the if __name __== __"main"__
block. All you global variables
must be initialized outside of the if __name __== __"main"__
(for example, by calling
initialize()
.)
Clarifications and discussion board
Important clarifications and/or corrections to the project, should there be any, will be posted on the ESC180 Piazza. You are responsible for monitoring the announcements there. You are also generally responsible for monitoring the ESC180 Piazza discussion board.
Hints & tips
- Start early. Programming projects always take more time than you estimate!
- Do not wait until the last minute to submit your code. You can overwrite previous submissions with more recent ones, so submit early and often—a good rule of thumb is to submit every time you get one more feature implemented and tested.
- Write your code incrementally. Don’t try to write everything at once, and then compile it. That strategy never works. Start off with something small that compiles, and then add functions to it gradually, making sure that it compiles every step of the way.
- Read these instructions and make sure you understand them thoroughly before you start—ask questions if anything is unclear!
- Inspect your code before submitting it. Also, make sure that you submit the correct file.
- Seek help when you get stuck! Check the discussion board first to see if your question has already been asked and answered. Ask your question on the discussion board if it hasn’t been asked already. Talk to your TA or your instructor.
- If your email to the TA or the instructor is “Here is my program. What’s wrong with it?”, don’t expect an answer! We expect you to at least make an effort to start to debug your own code, a skill which you are meant to learn as part of this course. And as you will discover for yourself, reading through someone else’s code is a difficult process—we just don’t have the time to read through and understand even a fraction of everyone’s code in detail. However, if you show us the work that you’ve done to narrow down the problem to a specific section of the code, why you think it doesn’t work, and what you’ve tried to fix it, it will be much easier to provide you with the specific help you require and we will be happy to do so.
How you will be marked
We will mark your project for correctness. That is, your functions must work as described below. Below, we give some suggestions for imroving the readability of your code. You will not be marked on the documentation or style of your code, although we encourage you to document your code anyway.
Correctness
We will run your functions using a Python 3 interpreter. Please ensure that you are running Python 3 as well. To check what version of Python you are running, you can run the following in your Python shell:
import sys
sys.version
Syntax errors in your code will cause your mark to be 0. Make sure that you submit a file that does not contain syntax errors. If the file contains syntax errors, you will see that on Gradescope right away. Note that your functions must be implemented precisely according to the project specifications. Their signatures should be exactly as in the project handout, and their behaviour should be exactly as specified. In particular, make sure that functions do not print anything unless the project specifications specifically demand that, and that the functions return exactly what the project handout is asking for.
Documentation
...
Gamification is the integration of elements found in games – such as points and badges – into nongame activities. One example of gamification is students’ being awarded badges and points for completing exercises in online courses. This is done in order to encourage students to complete the exercises. Another example is supermarkets awarding points to customers for purchasing various items. This is done, in part, to induce the customers to purchase more items in order to gain more points. In this project, you will implement a simulator for an app that encourages the user to exercise more by awarding “stars” to the user for exercising. The simulator will model how the user behaves, and could be used to try out various strategies for awarding stars. We imagine the user as accumulating “health points” and “fun points” (sometimes called hedons). Every activity is associated with gaining some number of health points and some number of hedons. Receiving a star increases the number of hedons that the user gains from performing the activity. Receiving too many stars too often makes the user lose interest in stars altogether. The simulation proceeds as a series of operations, which are simulated using calls to the functions that you will define. For example, a simulation might proceed as follows:
if __name__ == ’__main__’:
initialize()
perform_activity("running", 30)
print(get_cur_hedons()) # -20 = 10 * 2 + 20 * (-2)
print(get_cur_health()) # 90 = 30 * 3
print(most_fun_activity_minute()) # resting
perform_activity("resting", 30)
offer_star("running")
print(most_fun_activity_minute()) # running
perform_activity("textbooks", 30)
print(get_cur_health()) # 150 = 90 + 30*2
...