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

CPSC 217: Assignment 4 (The Game Of Life)

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.

Sections for this assignment

Program writing portion: New Concepts to be applied for the assignment (worth a max of 4.15 GPA)

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. For this specific assignment: most students will find it to be quite challenging (so if you are in this boat then that's perfectly normal). Most students in introductory programming courses complete most-all functional requirements so it is a challenge that you have a reasonable chance of meeting if you have approached this course (and assignment) properly. (In some other post-secondary institutes the instructor may not require file input to be implemented but typically less information is provided i.e. just the 'rules' for the births and deaths). Peptalk speech: If it helps, this assignment has been completed by grade 11 students in a Calgary high school. That definitely indicates that it is a 'doable' challenge for you.

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.

Critical design requirements

All instructions must be enclosed within the body of a function1, you must write at least 5 functions (JT's solution to A4 including 10 functions) of your own. Of course the functions must follow good design principles for functions. Functions that I have created in the starting code isn't included in the count. The functions you write must be properly implemented.   No global variables  may be employed. The exceptions to having statements outside of a function could include: import statements (not really needed for this assignment), the creation of global constants (e.g. ATTIC = 1), a global debugging flag (which is a variable) and the call to the initial start or main function.

This time around you won't be given a list of specific functions that you need to implement. There's two reasons for this:

  1. Providing a pre-created design will constraint students who may think of a different (but still perfectly valid) design.

  2. To give you practice decomposing a program into functions. If you aren't required to do this on your own at least once then you will never be able to do this on your own which makes all the other lessons on functional decomposition rather useless because you won't be able to apply them when writing programs.

If you are having trouble coming up with candidate functions then try reviewing the lessons on functional decomposition in lecture (the initial decomposition exercise was very simple because it was covered early in the semester) As well you should attend tutorial and try out the more advanced version of the decomposition exercise TAs will cover for finding the candidate functions. Since you are more experienced now, the Teaching Assistants can cover a more advanced example sometime after they have gone over lists. As mentioned you should have been attending class and taking note of the lessons on a regular basis but this is a hint about the important material for those who haven't always been in attendance. A direct link isn't provided here because requiring you to go through all the material will help you catch up on important concepts that you should have studying.

Summary:

You are to implement a text-based biological simulation: Conway's "Game of Life". Given a starting pattern of life forms that comes either from: 1) one of the 6 hard-coded (fixed) starting patterns in the starting code OR 2) read in from file your program will apply the [rules of births and deaths] on a turn-by-turn basis. At the end of each turn the before and after state of the simulation will be displayed to the user. There will then be an option to continue the simulation or quit the program. If the 'hidden' option is selected then [debugging mode] will be toggled.

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

Debugging mode

Entering 'd' or 'D' will toggle debugging mode (False becomes True, True becomes False). The flag 'debugOn' will track whether debugging message are to appear or not and by default the mode is 'off'.

    debugOn = False

When the flag is set to 'True' debugging messages will appear, otherwise they will not:

    if(debugOn == True):
        print("<<<Some debugging message>>>")

The exact content of the debugging messages is left to your discretion. As the name implies the debugging tool should be used to help you test and debug your program. Here are examples of debugging messages: 1) Display greater details: the neighbor count as well as births and deaths for each square  2) More sparse announcements specifying only where births and deaths have occurred. Again you are not bound to produce these exact messages in order to get credit for the debugging feature but they are provided to give you an idea of how you can use this feature to test your program.

This global variable for the debugging flag is the sole exception on the prohibition on the use of global variables in your program. No penalty will be applied for using this debugging flag but the usual penalty will be applied for other global variables e.g.

turn= 1

def display(oldWorld,newWorld):

    print("Turn #%d" %turn)

If you are still having trouble figuring out how a debug flag can be used in your assignment an was covered in tutorial but linked here for your convenience [example program: 8boardGameSolution_with_DEBUGGING].

Global constants (e.g. SIZE = 10) should be used when appropriate. Penalties for lack of constants may be applied when it's appropriate to define one and one hasn't been defined for that program.

Rules of births and deaths

The births and deaths of critters is based solely upon the number of neighbors in adjacent/neighboring squares. For each of the squares in the biosphere a count of the neighbors must be performed and based on the count the following rules will be applied.
 

If the an existing square in the old world is empty then a birth may occur in the corresponding location in the new world if:

If the an existing square in the old world contains a critter then a death will occur in that corresponding location in the new world if:

If the an existing square in the old world contains a critter then the critter will continue living in the corresponding location in the new world if:

Each square will have from 3 - 8 neighboring squares (inner squares have 8 neighbors, outer squares can have 3 at the corners or 5 on the top/bottom/left/right edges).

? = the square to check for a birth or death

N = a neighboring (adjacent) location in the list

Inner squares (1,1) to (7,7): 8 neighbors

N N N
N ? N
N N N

Four corners (0,0), (0,9), (9,0), (9,9): 3 neighbors

(0,0) (0,9) (9,0) (9,9)
? N
N N
N ?
N N
N N
? N
N N
N ?

Left, top, right and bottom

                   
                   
                   
                   
                   
                   
                   
                   
                   
                   

Hint for reading the pattern from file (how to see the invisible characters in a text document).

Open the input file using Word (you should be able to access Word via the student license for Office 365 without charge while you are U of C student) and here's how you turn toggle the display of 'Formatting marks':

Characters that aren't visible such as spaces, tabs and the newline (enter) appear in this display mode. Here's how to see formatting marks in MS-Word on an Apple computer (because the university is unable to provide a MAC to the course instructor the correctness of the contents of this link could not be verified): [Viewing formatting marks on a MAC]

Links to online web-based executable versions of the Game of Life to allow you to see how the simulation progresses.

In addition to grading on whether the above functionality was correctly implemented TAs will also look at documentation and style.

Naming the file containing your program

Implement a program with the features listed under the functional requirements. You must save your program in a file called "gol.py" (short for "game of life"). Failing to use this exact name will affect your grade.

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, for this assignment there is no maximum cap on the number of style penalties that may be applied (8 categories of penalties means a penalty of -0.8 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)

Marking and grading

Collaboration:

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

Method of submission:

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.

D2L configuration for this course

Late submissions for full assignments  when there is no extension granted: Make sure you give yourself enough time to complete the submission process so you don't get cut off by D2L's deadline (or your submission will be automatically flagged as late by D2L and it will be graded appropriately)..

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)

Use of pre-created Python libraries:

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. You cannot use a pre-created method (e.g. those specified in the copy module) to copy one list to another.

Short answer portion (Worth 0.15 GPA)

It will completed as a D2L quiz which will be opened for access 72 hours before the due date and will close at the same day/time as the Dropbox assignment link for A4. The 72 hours means that you have 3 days in total to complete this portion of the assignment (you are not limited in the amount of time you have to write the short answer within the 3 day window).

One question will come from the lecture notes "Introduction to Computer Science" while the other question will come from the lecture notes "Computer history". During the time it's available you can find the quiz in D2L under: Assessments->Quizzes->A4 short answer. Similar to assignments you can use resources such as the lecture notes, extra notes that you take during class etc. Your answers must come from the lecture material. You cannot simply "Google" some answer from some website or websites you find in the search results. Similar to assignments and examination you cannot collaborate with other students.

Submitting your work (D2L quizzes):

Finding your grade for the short answer portion

After grading is incomplete you can find your grade for the Short answer portion in D2L under: Assessments->Grades. You won't see it in the D2L Dropbox because you supplied your answers as a D2L quiz not along with the python program part of this project. I will be marking this portion of Project Part II so if you have questions then you can direct them to me but you should be able to see any written feedback (as needed) by looking at the quiz itself under: Assessments->Quizzes->A4 short answer

Mapping of raw score to grade point for the short answer portion

Min raw score GPA
0 0
1 0.03
2 0.045
3 0.06
4 0.075
5 0.09
6 0.105
7 0.12
8 0.135
9 0.15