To the faculty page of James Tam | Return to the course web page |
Due at 4 PM. For assignment due dates see the main schedule on the course webpage. The program must be written and run under python version 3.X and run on the computers in the tutorial labs.
Students may find assignments more challenging than they first thought. It's best to start work as early as possible. Tips in the very first lecture were provided but here's two reminders: 1) work through the lecture and tutorial material before looking in detail at the assignments 2) start work as soon as possible. If you find you cannot complete an assignment before the due date then you will not be granted an extension.
Note: it is not sufficient to just implement a working program and expect full credit. This requirement exists so you implement your solution in the correct way using good design principles and you apply the necessary concepts. Even if your program is fully working and the program is not designed or implemented as specified in the assignment description (e.g. poor variable names used, named constants, functions not implemented appropriately or insufficiently etc.) then you will not be awarded full credit.
Your program must be decomposed properly into functions. One way of decomposing your program is to include all the instructions needed for a room as a single function (or you can subdivide things further i.e. the code for a room is split between multiple functions). Because there are three rooms that will mean that your program will consist of at least 4 functions (1 per room plus a starting function). You may be able to subdivide your program using an alternate approach to writing 1 function per room but your program must follow [principles of good design for using functions].
Only new concepts that need to be applied in the assignment are listed, concepts previously applied in other assignments may need to used in the implementation of your solution.
All instructions must be enclosed within the body of a function, at least 4 functions must be properly defined and follow good design principles for functions. No global variables may be employed. The exceptions to having statements outside of a function: import statements (not really needed for this assignment), the creation of global constants (e.g. ATTIC = 1), a global debugging flag (if you choose to employ one, not mandatory for this assignment) and the call to the initial start or main function.
You will be penalized heavily if functions are not used or improperly used.
In a similar fashion you will be penalized heavily if you define or use global variables (global constants are okay, if you don't know the difference between constants and variables then refer to the "Intro programming" lectures covered at the start of the term).
When any global variables (not a debugging flag and not constants) are employed then you will be penalized a full grade point (1.0). To rephrase: This penalty applies if you define one or more global variable(s).
Example:
As you can see in the official University of Calendar calendar description CPSC 217 is a procedural programming (decomposing a program into functions). If you by the end of the term don't implement your programs using functions or you don't do so properly (following commonly accepted good style requirements) then you have missed the point of the whole course. So the restrictions help ensure that students can only attain a certain grade if they can demonstrate this. Note: these requirements don't mean that you have implemented all the features correctly. Instead it just shows that you can apply the necessary concepts properly.
Living room contents: a pot of soil, stairs going up, a dark entranceway, a ball of a string
(Actions you must implement for the living room).
- Viewing the pot of soil: 1) Default state when viewed, it looks dry 2) After it's been fertilized by the mouse (from the bedroom), when the player views the pot again a vine will grow that takes the player to paradise (game won and the program ends).
- Stairs going up: takes the player to the attic.
Dark entranceway: takes the player into the bedroom. Ball of string: the player can pick up this object. There is only one ball of string, once picked up the string should not appear again in this room. Attic contents: a tiny hole in the floor, an unlimited supply of cheese, stairs going down.
(Actions you must implement for the attic).
- Hole: 1) player can pick up some cheese and try to drop it down the hole, the game indicates that the cheese is too big (this won't have any effect on the player's inventory because the player will not keep the cheese after trying to drop it down the hole) 2) If the player has the string then a new option is provided which is to drop the string down the hole. When this occurs the string should be removed from the player's inventory (the string doesn't reappear anywhere in the game, nor does the option to drop the string down the hole appear again in this room). The effect of dropping the string down the hole will be seen in bedroom.
- Cheese: player can pick some up, the supply of cheese is unlimited so repeatedly picking up the cheese won't diminish the supply (or change the room description). However the game should track that if the player is carrying any cheese (this will allow the player to feed the mouse this cheese in the bedroom). And the inventory will only track the cheese as being in the player's inventory if the player explicitly picks it up with the intention of keeping it (and not just when the player tries to drop it down the hole and then sets it down again).
- Stairs going down: takes the player back down to the living room.
Bed room contents: a tomcat which is intently watching a mouse hole (default), mouse (after the cat leaves).
(Actions you must implement for the bed room).
- Tomcat: when the player isn't carrying the string no interaction is displayed. When the player is carrying the string then there is a option to use the string to play with the cat. The result is the cat looks briefly at the player and then goes back to watching the mouse hole (the motion isn't enough to greatly distract the cat).
- Mouse: after the player drops the string down the hole from the attic the large motion distracts the cat sufficiently enough to leave the room and he takes the string with him. The mouse then comes out of its hole. The game will then indicate that the mouse is in the room. If the player is not carrying any cheese then the game will only indicate that there is a mouse in the room but there is not opportunity to interact with it. Only if the player is carrying some cheese will the game display an option to feed the cheese to the mouse. When this occurs the mouse will leave the room and fertilize the pot of soil. (The vine will grow and the player will win the game when the soil is viewed again from the living room). After fertilizing the soil the mouse will return to the room so there is the possibility of the player repeatedly feeding the mouse (the amount feed to the mouse is negligible so it doesn't change the amount carried by the player i.e. the player can still feed the mouse without picking up more cheese from the attic).
- Recap: the game provides an option to feed the mouse only if the player ever picked up any cheese and if the cat has been replaced with a mouse. Each time the mouse has been fed then the program doesn't check/change the player's inventory.
- Dark entranceway: takes the player into the living room.
As was the case with the previous assignment each room will provide a description of the contents, display a menu of options (which varies depending upon the state of the game), get and error check the player's selection and display the menu and description for the room as long as the player remains in that location.
Game walkthrough: because this program is more complex than the previous one the above summary map cannot provide details of what the player needs to do in order to win the game. Similar to an actual game a text step-by-step walkthrough specifies what's needed to win the game.
- Living room: Pick up the ball of string.
- Living room: go up the stairs to the attic.
- Attic: drop the string down the hole.
- Attic: pick up some cheese.
- Attic: go down the stairs back to the living room.
- Living room: go through the dark entranceway to the bedroom.
- Bedroom: Feed the cheese to the mouse.
- Bedroom: go through the dark entranceway back to the living room.
- Living room: view the pot of soil (and win the game).
function attic()
Do while (player is in the attic)
Display options for attic
Get player's selection
Take appropriate action based upon the selection
End while
end function
function bed room()
Do while (player is in the bed room)
Display options for bed room
Get player's selection
Take appropriate action based upon the selection
End while
end function
function living room()
Do while (player is in the living room)
Display options for living room
Get player's selection
Take appropriate action based upon the selection
End while
end function
function start()
Do while (game has not yet been won) #Main program loop
if (location is living room) then
call function for living room
end if
else if (location is attic) then
call function for attic
end if
if (location is bed room) then
call function for bed room
end if
End while
Run end game instructions
end function
You can find sample outputs of my solution to this assignment in a link to this [Link to the folder containing outputs].
In addition to grading on whether the above functionality was correctly implemented TAs will also look at documentation and style.
General programming style requirements (-0.1 penalty for each violation of a category 7 categories of penalties means a maximum penalty of -0.7 will be applied)
- Naming conventions: You should employ good naming conventions for identifiers (variables, constants and even function names) as covered in the "Intro to programming" and "Functional decomposition" sections of the course. Also note there is a specific name that you should give to the file containing your program which is specified under the [marking and grading section].
- Named constants should be used as appropriate (and if they aren't a penalty will be incurred).
Yes do it this way! No. Not this way! LEFT = 0
RIGHT = 1
CENTER = 2
if (silverLockPosition == RIGHT):if (silverLockPosition == 0): #What does 0 stand for???
- The program code should have appropriate white space (specified in the "Intro to programming lecture') and alignment (specified throughout the lecture notes).
- Code is self documenting e.g. Clear expressions (e.g. mathematical, Boolean). Expressions should be clear and simple (break up or restructure complex expressions). Good variable names and the use of named constants are examples of writing self documenting code but specifying clear expressions is important enough to be included in a separate category.
- Your program should follow the 5 rules of thumb for designing user friendly software (distilled from Jakob Nielsen's 10 usability heuristics - see the Usability Heuristics in the [Part III of the looping/repetition notes]). e.g. good error handling (such as prompts to the user to enter the required information clearly indicate what is required, good error messages/error handling should be provided for erroneous input) minimizing the user's memory load, being consistent, providing clearly marked exits & providing feedback as appropriate. This includes but is not limited to having the menu selections for choosing the action for each room being intuitive.
- Of course if a student implements an extreme case of inefficient code (e.g. multiple loops or branches are used when one will do) then penalties may be applied but this is generally rare.
- The program should not employ abnormal termination mechanisms e.g. something such as a 'break' instruction for loops or calls to the 'exit()', 'quit()' functions anywhere in the program.
- Having at least one violation in one of the above general style requirements will result in -0.1 penalty to marking. Multiple violations in one category still results in a single penalty (e.g. 3 bad variable names will still result in a -0.1 penalty). However violations between categories will result in cumulative penalties (e.g. a program that includes poor variable names, messy program layout and poor error handling will receive a -0.3 penalty)
Function specific style requirements (principles of good design for functions) -0.2 penalty will be applied for each of the 3 function specific style requirements that have been violated.
- Functions are one screen in length (normal screen 40 lines max of code (the count excludes whitespace and documentation).
- Functions implement one well defined task (e.g. processLivingRoomCommands vs. processlivingRoomRunIntroductionRunConclusion).
- Code in one function is not duplicated in another function (not in the notes but this is just common sense that you don't write two functions where there's overlapping code - the overlap should likely be taken out of both functions and moved to another separate function). In this assignment there may appear to be some overlap (e.g. each room displays a menu of options but the specific options displayed will not be identical.
- Violating any of the function specific style requirements will result in a -0.2 penalty for a violation in each of the 3 categories. E.g. a program that includes a function that exceeds the maximum length and implements two or more tasks would incur a -0.4 penalty.
Documentation requirements:
- Header documentation: This should be specified in the header of the program (very top of your program in the form of Python documentation). The basics of documentation were covered in the "Intro to programming" section of the course.
- Identifying information: All assignments should include contact information (full name, student ID number and tutorial section [Here's a link if you don't know how to find this information]) at the very top of your program.
- Program version. (version date or version number).
- Under the version you should specify which assignment features were implemented in that version as specified in the [last part of the "Intro to programming"] section of the course.
- Any program limitations or weaknesses.
- New documentation requirement starting with this assignment and applies to all successive assignments: [Inline documentation] (provided just before each function is defined): list the features of each room that were implemented in a particular function, the return type(s) as well as the type(s) of the arguments.
Program functionality (implementing working program features)
Test your program: Because the [marking key] is posted ahead of time if you test your program thoroughly before submitting the final version then you should get a pretty clear idea of "how you will do".
Style and documentation (non-functional assignment requirements)
- Style and documentation requirements were introduced early in the semester in the [last part of the "Intro to programming"] section of the course. Additional requirements may be added as new sections are covered (e.g. documenting functions that you write your yourself). Each assignment will specify these requirements specific [under the non -functional assignment requirements (style and documentation). ] to that graded component. Again you should refer to the [marking key] in order to determine how style and documentation will affect grading for a particular assignment.
Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others. Some "do nots" for your solution: don't publically post it, don't email it out, don't show it to other students. For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that you submit your assignment with enough time before it comes due for you to do a check). If don't check and there were problems with the submission then you should not expect that you can "learn your lesson" and simply resubmit.
Submission received: |
On time |
Hours late : >0 and <=24 |
Hours late: >24 and <=48 |
Hours late: >48 and <=72 |
Hours late: >72 and <=96 |
Hours late: >96 |
Penalty: |
None |
-1 GPA |
-2 GPA |
-3 GPA |
-4 GPA |
No credit (not accepted) |
Unless otherwise told you are to write the code yourself and not use any pre-created functions (or methods). For most assignments the usual acceptable functions include: print(), input() and the 'conversion' functions such as int(), float(), str(). Look at the particular assignment description for a list of other functions/methods that you are allowed to use and still get credit in an assignment submission. If it's not listed then you should assume that you won't be able use the function and still be awarded credit.
1 Choose your own adventure. Rather than passively reading through a fixed story written by the author a choose your own adventure puts you in the role of the story's protagonist whereby you can determine the outcome of the story by choosing at various points the direction that will be taken by the story.