To the faculty page of James Tam Return to the course web page

CPSC 217: Assignment 2  ("The Dungeon of Doom": the Inner Sanctum)

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.

Assignment difficulty

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].

New Concepts to be applied for the assignment

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.

Critical design requirements

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.

Functional requirements (working features of your program, for the marks allocated for each feature see the marking spreadsheet):


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).

Attic contents: a tiny hole in the floor, an unlimited supply of cheese, stairs going down.

(Actions you must implement for the attic).

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).

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.

  1. Living room: Pick up the ball of string.
  2. Living room: go up the stairs to the attic.
  3. Attic: drop the string down the hole.
  4. Attic: pick up some cheese.
  5. Attic: go down the stairs back to the living room.
  6. Living room: go through the dark entranceway to the bedroom.
  7. Bedroom: Feed the cheese to the mouse.
  8. Bedroom: go through the dark entranceway back to the living room.
  9. Living room: view the pot of soil (and win the game).

Overall program design

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

Sample outputs of this program:

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.

Non-functional assignment requirements (style and documentation).

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)

  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???

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.

Documentation requirements:

How to do determine 'how you did' on an assignment?

Program functionality (implementing working program features)

Style and documentation (non-functional assignment requirements)

Marking and grading