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

CPSC 217: Assignment 3 (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.

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.

Assignment difficulty

Students may find assignments more challenging than they first thought. It's best to start work as early as possible. During the first week of lecture [4 tips for success were covered] 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 by these other institutes 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 although the assignments is a challenge 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  of your own. (JT's solution to the assignment included 10 functions). 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 except for the one(s) used for the [debugging mode].  The exceptions to having statements outside of a function could include:

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 throughout the semester.

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 (Toggle means to reverse the state: 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 for this assignment:

  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. Implementing something similar to the following in your program will warrant a penalty:

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]

Summary of programs related to this assignment:

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.

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

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 obviously "do nots" for your solution: don't publically post it, don't email it out, don't show it to other students nor should you verbally discuss it.  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].

Method of submission:

Reminder: You are to submit your assignment using D2L  Here's a UC-IT created [D2L help resource] . 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, it is the correct file 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 Whatever you submitted into D2L by the final due date (and due time) is what will be marked.

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(),  range() - the latter is actually not actually a function but a composite type such as string or a list but it looks like a function. 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