Assignment 6
Assignment 6
Assignment 6
Inheriting Conway
General Instructions
• This assignment is individual work. You may discuss questions and problems with anyone, but
the work you hand in for this assignment must be your own work.
• Assignments are being checked for plagiarism. We are using state-of-the-art software to com-
pare every pair of student submissions.
• Each question indicates what to hand in. You must give your document the name we prescribe
for each question, usually in the form aNqM, meaning Assignment N, Question M.
• Make sure your name, NSID, student number and course number aappear at the top of every
document you hand in. These conventions assist the markers in their work. Failure to follow these
conventions will result in needless effort by the markers, and a deduction of grades for you.
• Do not submit folders, or zip files, even if you think it will help. Unless given permission to do so.
It might help you, but it adds an extra step for the markers.
• Assignments must be submitted to Canvas. There is a link on the course webpage that shows
you how to do this.
• Canvas will not let you submit work after the assignment deadline. It is advisable to hand in
each answer that you are happy with as you go. You can always revise and resubmit as many
times as you like before the deadline; only your most recent submission will be graded.
• You may only use methods and modules explained in class, unless explicitly told otherwise. If you
wish to use another module first check with the professor.
• Read the purpose of each question. Read the Evaluation section of each question.
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Within this course the statement "code for whomever comes next" had been said providing, TAs and your-
self in the future as examples. Now you get to examine what your previous self has coded and reflect on
the this idea.
RECALL Assignment 1 Question 3, parts A and B have already been completed by you. The parts A and B
are merely here to remind you what was expected. The code itself is not the primary focus the reflection
and critical thinking is what matters. Within this assignment question you will be expected to complete
only parts C and D.
Now using your original submissions reflect on the previous design and code, and extend Conway’s Game
of Life even further.
Conway’s game of life, aka Game of Life, aka Life is a zero player game developed by the British mathe-
matician John Horton Conway in 1970. The game’s evolution is determined by its initial state and requires
no further input. One interacts with the game by setting up the initial input, and observing how the input
evolves.
On a grid every cell interacts with its neighbouring cells; a cell is either alive ("*") or dead("-"). At each “Time
Step” (iteration) that occurs the following transitions are possible;
• Any living cell with less than 2 neighbours dies of loneliness.
• Any living cell with 2 or 3 neighbours remains alive.
• Any living cell with more than 3 neighbours dies of claustrophobia.
• Any dead cells with exactly 3 neighbours become alive, rising from the ashes like a phoenix.
Your task is to implement this game.
Page 2
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Expansion Specifications
These are the expanded requirements your solution must be able to satisfy.
• The grid can be a rectangle of any size.
• Consider all adjacent neighbours; up, up right, up left, down, down right, down left, left, and right.
• It must be possible to read in the initial state from a file (see the examples).
• The user will pass in an input file as an argument to the python script and the desired amount of
itterations (steps)
Example: python3 conway.py input4.txt 5
• The user will pass in the number of steps that should occur or else the default will be 3.
• The use should be asked if they also wish to see the results in the console.
If yes each step should be easily identifiable if no there should still be a way to let the user know when
the program is complete.
• The updated state should be saved to a new file with the same name as the input file followed by an
underscore and the amount of steps that have occurred.
Example: input1_nsteps.txt, where input1 was the original name and n is the number of itterations
that have occurred.
• Original rules related to cells being alive or dead still apply.
• Zombie Cells - cells that were initially dead but come back to life will now be denoted with a "Z".
• Zombie Cells can now infect neighbouring living cells after the cell has been a zombie for 1.
• The Zombie Cells are still considered "living" for the rules of the game only their symbol has change.
Page 3
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Write a design document in a markdown file (.md), markdown is a markup language. Typically markup
languages are used to control the display of a document or enrich the context of the document. Markup
languages are a set of rules governing what markup information may be included in a document and how it
is combined with the content of the document in a way to facilitate use by humans and computer programs.
Within your design document consider what options you have before you, consider the pros and cons of
the different options. Consider what assumptions you’re making and wha dependencies exist. What are
the goals of your code? How do you plan to accomplish your goals? Document design decisons and how
you plan to solve the problem.
Remember an important part of computer science is breaking up a big problem into easier to manage
sub-problems. As you write this document, COMMIT THROUGHOUT THIS PROCESS.
Page 4
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Test-driven development (TDD) is a software design strategy, use your design plan from Part A of this ques-
tion. Follow the TDD process based on the principles within your textbook.
An important aspect of this will be having an easy way to make sure as your tests increase and your code
increases you’re also making sure that previous test cases continue to pass (regression testing).
Make sure you are able to test multiple test cases without a user needing to compare and contrast print
statements on a terminal.
To do this keep in mind chapter 7 of the textbook, and the importance of test scripts, aka test drivers. Au-
tomating tests so you only need to worry if tests have failed or what tests were unsuccessful can assist
in determining where errors may exist. A test should contain input, output, and the purpose of the test.
You can go further with your testing by grouping together tests that are related to a specific function or
element of your code. However, so long as your test cases are easy to understand and readable this is not
mandatory.
Consider how the different aspects of your code will interact with each other when writing test cases (in-
tegration testing).
Rather than having both your tests and your implementation code within the same file, you are required to
have your tests within a separate python file that imports the file containing your implementation of Con-
way’s Game of Life.
Page 5
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Part C - Retrospective
You are now looking at this code months after it has been written rather than minutes.
Page 6
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
What to Hand In
• Part C - The retrospective should be named a6q1_retrospective.txt
• Part D - The updated implementation should be named a6q1.py
• Part D - The updated test file should be named a6q1_testing.py
• A gitlog associated with the assignment as a whole named a6.log. Clearly identify commits made for
each question. Examples:
A # Q # - Commit Title
A # Q2 - Added provided files for question # to repo
A # Q4 - Implemented function _____ to allow
for ______ to pass .
Be sure to include your name, NSID, student number, course number and section number at the top of all
documents (including your git log).
WARNING: Marks can be deducted if instructions are not followed, or if the answers are not legible.
Evaluation
WARNING: Marks can be deducted if instructions are not followed.
WARNING: If resources not identified you risk getting 0 for this assignment question.
• 29 marks: Part C
– Evidence of critical analysis of the original works as whole must occur to get marks.
– 8 marks: Reflection on the original work (2 marks for each sub-question)
* 1 mark: The answer mark for the reasoning
* 1 mark: At least 1 example.
– 15 marks: Software design and Implmentation goals (3 marks for each goal)
* 1 mark: Justification of something done well (relating to the goal).
* 0.5 marks: Example of something done well (relating to the goal).
* 1 mark: Justification of something that could be improved upon (relating to the goal).
* 0.5 marks: Example of something that could be improved upon (relating to the goal).
– 3 marks: Expanding the code - Documenting changes made to your code and why.
– 3 marks: Key takeaways
* 2 marks: Lessons learned and why (at least 2).
* 1 mark: Things to work on/ avoid in the future and why.
• 20 marks: Part D.
– 18 marks: 0.5 marks for Implementation 1.5 marks for Testing
Page 7
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
Further Resources
• Wikipedia - Conways Game of Life
• Play Game of Life
• Part A Resources
– Please note that no singular method is best for writing your design document instead these are
ideas of what to consider including within your design document.
– Berkely - How to Write a Design Document
– Free Code Camp - How to write a good software design doc
– BIT.AI Blog - Software Design Document: What it is & How to Create it!
– Markdown Guide Cheatsheet
– Github Markdown Cheatsheet
– Wikipedia - Markup Languages
• Part B
– Spiceworks - What is regression testing
– Guru99 - How to write test cases
– Wikipedia - Integration Testing
– Examples of Testing Software*
• Part C / Part D
– Talks at Google - A Philosophy of Software Design - John Ousterhout
Page 8
Department of Computer Science CMPT 145
176 Thorvaldson Building Spring/Summer 2023
110 Science Place, Saskatoon, SK, S7N 5C9, Canada
Telephine: (306) 966-4886, Facimile: (306) 966-4884 Principles of Computer Science
What to Hand In
• A file titled a6q2_Container.py
• A file titled a6q2_Stack.py
• A file titled a6q2_Queue.py.
• A gitlog associated with the assignment as a whole named a6.log. Clearly identify commits made for
each question. Examples:
A # Q # - Commit Title
A # Q2 - Added provided files for question # to repo
A # Q4 - Implemented function _____ to allow
for ______ to pass .
Be sure to include your name, NSID, student number, course number and lecture section at the top of all
documents.
Evaluation
• Container Class
– 7 marks for implementation
– 3 marks for documentation
• Stack Class
– 1 mark for correctly setting up inheritance
– 2 marks for implementation
– 1 mark for documentation
• Queue Class
– 1 mark for correctly setting up inheritance
– 2 marks for implementation
– 1 mark for documentation
Page 9