ITECH 1400 Foundations of Programming
- Subject Code :
ITECH-1400
- University :
Federation University Exam Question Bank is not sponsored or endorsed by this college or university.
- Country :
Australia
1. Introduction.
In this assignment you are required to develop a Python program to run Conways Game of Lifeon a finiteboard.
Here are the definitions (from Wikipedia):
1.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 isan infinitetwo- dimensional grid of squarecells, each of which is in one of two possible states,aliveordead (1 or 0). Every cell interacts with its eightneighbours, which are the cells that are horizontally, vertically or diagonally adjacent. At each step, the following transitions occur:
- 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.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
The initial pattern constitutes theseedof 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:
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 ofGLTshould be implemented as a two-dimensional (???????? ????????)list of integers that contains onlyzerosandones.
- Elements of the list represent cells of GLTs 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 cellboard[i][j]should be computed by the following rules:
board[(i-1+n)%n][(j-1+n)%n],
board[(i-1+n)%n][j],
board[(i-1+n)%n][(j+1)%n], board[i%n][(j+1)%n],
board[(i+1)%n][(j+1)%n],
board[(i+1)%n][j], board[(i+1)%n][(j-1+n)%n],
board[i][(j-1+n)%n].
Wherenis the length of the boards 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 classmust havean attribute namedboard, which should be defined in the constructor. Theboardattribute 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 cellboard[i][j]. The neighbours ofboard[i][j]are listed in section 1.1.
nextPattern(self) changes the boards current pattern to the next one according to the games rules. See section 0.1.
printBoard(self) prints the current pattern, replacing zeros with white spaces and ones with *. Similar to the picture below:
2. Write main() function.
This is a driver program where you test your implementations as follows:
- Create three initial patterns (2D-lists) for the game. You may search the Internet for interesting patterns.
- Games should be played on the bord with dimensions2020.
- 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.
Get your ITECH 1400 Foundations of Programming "CONWAY'S GAME OF LIFE ON TORUS" assignment solved by our Programming Experts from Exam Question Bank . Our Assignment Writing Experts are efficient to provide a fresh solution to all question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing Style. Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered.
You may continue to expect the same or even better quality with the used and new assignment solution files respectively. Theres one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turn tin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.