Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 7 (Worth 8%)

Grading Scales

Grade out of 24 Letter
53 - 54 A+
51 - 52 A
48 - 50 A-
44 - 47 B+
40 - 43 B
36 - 39 B-
32 - 35 C+
28 - 31 C
24 - 27 C-
18 - 23 D+
12 - 17 D
6 - 11 D-
0 - 5 F

 

New concepts to be applied for the assignment

  1. Two-dimensional arrays
  2. Solving a more challenging problem

 

Writing a simple adventure game: The quest for the grade!

You are to write a text based adventure game for this assignment. The game world will be represented in an overhead two-dimensional view. Characters will represent different objects in the game

  Character Value represented
  S The student (controlled by the player).
  # A wall
  A, B, C, D Grades that can be awarded to the student (the 'F' never appears visibly and is awarded if the player quits the game).
  P The portal. When the student tries to enter the portal, it will ask for the password and only let the student pass if the correct one is given.
  ? The oracle. It provides the correct password to the player.
  K The key which can be 'picked up' by the student and is the only way in which the student can be awarded a grade of an 'A'.

The object of the game is for the student to be awarded the highest possible grade. The player can quit the game at any time but is awarded an 'F'. 'D' and 'C' grades are quit common. The 'B' grade is harder to obtain and requires some rudimentary puzzle solving and 'A' grade is the hardest of all to attain. When the student is awarded a grade the game will end and the game will display the grade that was earned. The game is turn based and each turn the player can: quit the game, move the student or toggle debugging messages on or off. When the player moves the student  the game will react differently depending upon the object that occupies the destination square. Empty squares contain a space and can be entered with no special effects. Squares containing walls cannot be entered. A square with a letter grade will result in that grade being awarded to the student and game ending. The exception is the square containing an 'A' which can only be entered if the student has first picked up the key. Entering the square containing the oracle will display the password to the player. Entering the square with the portal will query the player for the password. The student can only be moved to adjacent squares.

 

Features to be implemented
 
  1. Display an introduction each time that the game is run which provides instructions for playing the game: 1 mark
 
  1. Display a conclusion each time that the game ends. The conclusion must show the grade that was awarded to the student: 1 mark
 
  1. Display the game world in the same form as the sample executable: 1 mark
 
  1. Displays a menu that shows the allowable directions that the student can be moved which are mapped to the keypad on the keyboard. The menu should show the 4 cardinal compass points (N = 8, W = 4, E = 6, S = 2) as well as the inter-cardinal ones (NW = 7, NE = 9, SW =1, SE = 3). It should be indicated in the menu that selecting 0 will allow the player to quit the game: 1 mark
 
  1. Move the student when the direction selected is 1-4 or 6-9. The student will 'disappear' off the source square and 'reappear' on the destination square: 6 marks
 
  1. End the game when direction selected is zero. The student will be awarded an 'F' in the grade and the conclusion should be displayed: 1 mark
 
  1. The student is prevented from moving into solid walls: 2 marks
 
  1. A grade is awarded when the student is moved onto a square containing a 'B', 'C' or 'D'. When this occurs the conclusion should be displayed and the program will end: 2 marks
 
  1. The game performs boundary checking. The game can determine when the player attempts to move the student outside the bounds of the array: above the first row, below the last row, left of the first column or right of the last column. Your game will implement one of the two approaches listed: 2 marks maximum
   
  1. First approach: implement a barrier. When the player tries to move the student outside the bounds of the array the game will display an error message and it will not move the student. (1 mark)
   
  1. Second approach: implement a wrap-around effect. When the player tries to move the student outside the bounds of the array the game will move the student to the opposite side of the world: when the student is moved above the first row it will reappear at the same column but at the last row, when the student is moved below the last row it will reappear at the same column but at the first row, when the student is moved left of the first column it will reappear in the same row but in the last column and when the student is moved right of the last column it will reappear on the same row but in the first column. (2 marks)
 
  1. The oracle is activated. The password will be displayed when the student moves onto this square (2 marks). If after this the game reminds the player of the password each turn then an additional mark will be awarded: 3 marks maximum for this feature
 
  1. The portal is activated. The portal will ask the player for the password "nok nok" when the student tries to enter this square. If the correct password is given then the student may enter otherwise a refusal message is displayed and the student cannot enter. Note the important part is that the player must give the correct password and it does not necessarily mean that the student actually visited the oracle first (e.g., the player knows the password because he or she has played the game before): 2 marks
 
  1. The student can 'pick up' the key by entering the square where the key resides. When this occurs the game should display an appropriate message to the player (2 marks). If the game continues to remind the player each turn that they have key then an extra mark will be awarded: 3 marks maximum for this feature
 
  1. The 'A' is treated as a special case. The student can only enter this square and be awarded an 'A' if the key was picked up beforehand. Otherwise the student will not be able to enter this square: 4 marks
 
  1. The game allows debugging messages to be displayed. The game implements a hidden option for the directional menu. If the player enters a negative value for the direction then the program will toggle debugging messages on and off.   The exact content of the debugging messages is left to your discretion. As the name implies they should be helpful for debugging your program or helping to verify if it does what it is supposed to. Typical debugging messages show the state of the program at different execution points: a message appears as a particular module executes or the contents of variables are displayed (e.g., as the student is moved, the program shows current row/column coordinates of the student, the direction to be moved and the row/column coordinates for the destination). You can try running the sample executable to see examples of debugging messages: 3 marks

 

Submission requirements

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

  1. Include a README file in your submission:  For this assignment your README file must include your contact information: your name, university identification number and UNIX login name so that your marker knows whose assignment that he or she is marking.   For this assignment you should also list the features of the game that you actually implemented.

  2. Assignments (source code/'dot-p' file and the README file) must be electronically submitted.  In addition a paper print out of the source code and README must be handed into the assignment drop box (located on the second floor of the Math Sciences building) for the tutorial that you are registered in.  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and flip through your source code.  Unless you are told otherwise you are to email your source code and readme file to your TA and to me.  Make sure that include the following information in the subject line: "CPSC 231 Assignment X" where 'X' stands for the assignment number that you are submitting e.g., "CPSC 231 Assignment 3".

  3. As a reminder, you are not allowed to work in groups for this class.   Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following link.

To help make sure that you haven't missed anything here is a checklist of items to be used in marking.  A sample executable 'quest' can be found in UNIX under the directory: /home/231/assignments/assignment7.