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

CPSC 231: Assignment 7 (Worth 5%)

Grading Scales

Ranges Letter
23 - 24 A+
21 - 22 A
19 - 20 A-
17 - 18 B+
15 - 16 B
13 - 14 B-
11 - 12 C+
9   - 10 C
6   - 8 C-
3   - 5 D+
2 D
1 D-
0 F

Outline for designing your program

 

New concepts to be applied for this assignment

 

Assignment description

You are write the code for the "Squirt the weed" game.  The game will model a garden in which weeds randomly sprout up and the player must 'squirt' a location before a weed grows there.  (That is, the player must predict where weeds may sprout up in the future).  The 'garden' will be implemented as a two dimensional character array.  Time passes in the game in the form of turns.  During each turn the game will display the state of the garden from the previous turn.  The player will be prompted for the row and column coordinates of the square that he or she wishes to squirt.  Each turn the player can only squirt one square.   In the full game there will be a maximum of 8 weeds under the soil that sprout up each turn.  At the start of the turn the weeds will retract (i.e., the square is cleared) and the program will randomly determine the new location for each weed to appear.  If the player correctly predicted where a weed sprouts, the weed has been 'squirted' and won't re-grow the next turn (the maximum number of weeds that sprout up the next turn will be reduced by one).   The game continues on a turn-by-turn basis until: 1) Fifty turns have elapsed 2) The player quits the game 3) The player has 'won' the game - he or she has successfully predicted where all the weeds will sprout (the player has squirted all eight weeds)  

 

Grading

(Bare bones) basic assignment (worth 6 marks)

 

Extra features:

Once you complete all the features of the basic assignment you can complete the extra features for additional credit (make sure you backup your work first and don't touch the working back up, modify a copy instead!)   Unless there are technical considerations you can complete these extra features in whatever order or combination that you desire.  (For example: It's makes no sense to let the player win the game if he or she can't even select a square to squirt).

  1. The game prompts the player for the row/column coordinates of the square to squirt.  If the user enters -1 for either the row or column then the program will end.  If the user enters -1 for both the row and the column then debug mode will be toggled.  (If was off then it will be turned on, if was on then it will be turned off): 2 marks
  1. The games checks that row and column values entered by player are within the bounds of the array: 2 marks
  1. The game checks if the row, column coordinates entered by the user contains a weed.  If it does then the number of weeds is reduced by one.  Weeds that have been squirted will for one turn display the 'S' character (the squirted state).  After that the square can either show as empty (a space) or as another weed ('W'): 4 marks
  1. The game can determine if the game has been won (number of weeds left equals zero).  If this condition has been met then the game will end and a suitable congratulatory message should be displayed: 4 marks
  1. Multiple weeds can appear in the game.  If the ability to randomly generate the locations where weeds will sprout has not been implemented then the weeds will appear in the same locations from turn to turn: 2 marks
  1. The location that a weed or weeds will appear from the turn-to-turn is randomly determined.  The previous location which contained a weed will be cleared (as the old weed sprout dies) and the new location for the new sprout will be randomly determined.  For example, there are 3 weeds left in the game.  Last turn they appeared at (1,1), (2,2) and (4,3).  The garden is displayed to the player who then enters the row/column value of 3, 3.  The three locations containing weeds are cleared and the new coordinates (2,3), (3,3) and (1,4) are generated.  The weed at (3,3) is squirted and will show as a 'S' the next turn.  The weeds at (2,3) and (1,4) are displayed to player the next turn when he or she has to guess the new location of the remaining two weeds  : 4 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 that you 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 'weed' can be found in UNIX under the directory: /home/231/tamj/assignments/assignment7. 

Clipart image from: http://www.revelation-illustrated.com