Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ITECH 1400 Foundations of Programming SEMESTER 2, 2021 ASSIGNMENT 2. CONWAY'S GAME OF LIFE ON TORUS 35 MARKS 0. Introduction. In this assignment you are

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
ITECH 1400 Foundations of Programming SEMESTER 2, 2021 ASSIGNMENT 2. CONWAY'S GAME OF LIFE ON TORUS 35 MARKS 0. Introduction. In this assignment you are required to develop a Python program to run Conway's Game of Life on a finite board. Here are the definitions (from Wikipedia) : 0.1. The Classical Game of Life The Game of Life was invented by British mathematician John Horton Conway in 1970. The universe of the Classical Game of Life is an infinite two- dimensional grid of square cells, each of which is in one of two possible states, alive or dead (1 or 0) . Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically or diagonally adjacent. At each step, the following transitions occur: 1. Any live cell with fewer than two live neighbours dies, as if caused by under-population. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies, as if by overcrowding. 4. Any dead cell with exactly three live neighbours becomes A live cell, as if by reproduction. The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed - births and deaths occur simultaneously. The rules continue to be applied repeatedly to create further generations. Below are two examples of interesting initial patterns:Fig 2. Pulsar 0.2. The Game of Life on Torus (GLT) . In the assignment you are required to develop a Python program for the Game of Life restricted to a finite board (n X n) . It is same as the classical game of life except that we assume that the left border of the board is glued to the right border, and the top border of the board is glued to the bottom border. So, there are no borders, and the game is played on a torus. See the details in the next section. 1. Programming Tasks and Implementation Requirements. 1.1. The board of GLT . The board of GLT should be implemented as a two-dimensional (n xx]list of integers that contains only zeros and ones. . Elements of the list represent cells of GLT's universe: Zero elements represent dead cells, elements that are equal to one represent live cells. Transition rules (1-4) of the restricted game are the same as those of the classical game. Eight neighbours of the cell board[i] [j] should be computed by the following rules: board [ (i-1+n) \ ] [ (j-1+n) an] , board [ (i-1+n) @n] [j] , board [ (i-1+n) \ ] [(j+1) an] , board [itn] [(j+1) tn] , board [ (i+1) an] [(j+1) in], board [ (i+1) \ ] [j] . board [ (i+l) an] [ (j-1+n) \ ] ,Where n is the length of the board's side. The modulus ($) operator is used in the formulas for neighbours because the game will be played on a torus, not on a plane. See section 0.2. 1.2. Develop GameOfLife class. The class must have an attribute named board, which should be defined in the constructor. The board attribute is a two- dimensional square list as described in the previous section. You may define other attributes in your class, if required. Also, the class should define the following methods: neighbourSum (self,i,j) - the method computes and returns the number of live neighbours of the cell board[i] [j] . The neighbours of board[i] [j] are listed in section 1.1. nextPattern (self) - changes the board's current pattern to the next one according to the game's rules. See section 0.1. printBoard (self) - prints the current pattern, replacing zeros with white spaces and ones with "*'. Similar to the picture below: Python 3.9.2 (tags/v3.9.2:1279785, Feb 19 2021, 13:44:55) [MSC v. 1928 64 bit (AM D64)] on win32 Type "help", "copyright", "credits" or "license ()" for more information. === RESTART: C:/MyPlace/2021/Semester_2/ITECH1400/A2_ITECH1400/GameOfLife. py === 92. Write main () function. This is a driver program where you test your implementations as follows: Create three initial patterns (20-lists) for the game. You may search the Internet for interesting patterns. Games should be played on the bord with dimensions 20:20. Print the patterns on the screen and ask the user which one they would like to play with. Once the pattern is chosen, the game starts. During the game, after printing a new pattern, you should always ask if the user wants the next pattern to be printed or end the game. The game ends only when the user decides so. To print the meat pattern antar Y/y. To and the game antes any other symbol: y To print the next pattern enter Y/y. To end the game enter any other symbols yMarking Criteria/Rubric Student ID: Student Name : Tasks Weight Awarded Marks deducted for badly commented (-4) or badly written code class GameOfLife init 2 neighbourSum B nextPattern 10 print 6 main () function 2 foolproof prompts Creation of 3 GameOfLife 3 objects The game's menu Total 35+ (-4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions