Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 1.2. The Game of Life on Torus (GLT). In the assignment you are required to develop a Python program for the Game of Life

python image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1.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) 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 (nnnn) 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 (14) of the restricted game are the same as those of the classical game. 1. Programming Tasks and Implementation Requirements . 1.1. The board of GLT - The board of GLT should be implemented as a two-dimensional (nnnn) 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 (14) of the restrieted 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) in] [(j-1+n) in]. . board [ (11+n) \&n] [j], board [(i-1+n) 8n] [(j+1) 8n], board [1 n][(j+1) \& n], board [ (i+1)8n][(j+1)8n], board [ (1+1) \&n] [j], board [ (i+1) \&n] [(j1+n)n], board [i] [(j-1+n) \&n] . Federation Where n is the length of the board's side. The modulus (t) 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 deseribed 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: Federation 2. Write main() function. This is a driver program where you test your implementations as follows: - Create three initial patterns (2Dlists) for the game. You may search the internet for interesting patterns. - Games should be played on the bord with dimensions 2020. - 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. patterns. - Games should be played on the bord with dimensions 2020. - 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 $0. Federation Allocated Marks: See Course Description Due Date: See Course Description Please refer to the Course Description for information relating to late assignments and special consideration. Assignment Subenission You. must supply your program source code files and your documentation as a single zip file named as follows: YOUR-NAME>_. zip, e.g. John_SMITH_30000000 Support documentation should be in PDF format. Assignments wil1 be marked on the basis of fulfilment of the requirements and the quality of the work. In addition to the markinn \[ \begin{array}{c} \text { SYOUR-NAME } angle \text { _YYOUR-STUDENT-ID>. zip, } \\ \text { e.g. JOhn_SMITH_ } 30000000 \end{array} \] Support documentation should be in PDF format. Assignments will be marked on the basis of fulfilment of the requirements and the quality of the work. In addition to the marking criteria, marks may be deducted for failure to comply with the assignment requirements, including (but not limited to) : - Incomplete implementation (s), and - Incomplete submissions (e.g. missing files), and - Poor spelling and grammar. You might be asked to demonstrate and explain your work. Submit your assignment (all program source files plus your pdf document) to the Assignment 1 Upload location on Moodle before the deadline. Federation Marking Criteria/Rubric Student ID: Student Name: \begin{tabular}{|l|l|l|} \hline Tasks & Weight & Awarded \\ \hline Marks deducted for badly commented or badly written code & (4) & \\ \hline class GameOflife & & \\ \hline init_ & 2 & \\ \hline \end{tabular}

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

Students also viewed these Databases questions

Question

What are the various types of investments?

Answered: 1 week ago

Question

Discuss types of budgeting methods and provide one example of each?

Answered: 1 week ago