Question: Task 1 A: Building Randomly a Society [ 1 0 marks ] In this task, we are going to define the function build _ society
Task A: Building Randomly a Society marks
In this task, we are going to define the function buildsociety which builds an society
randomly populated with live and dead cells.
Assumptions
and
Output must be a list of lists
Note: As long as the result of your function returns an society randomly populated by dead and live
cells, your solution will be accepted. There is also no need to set the random seed for computation.
Example Run
:
Task B: Modeling a Society Marks
As we have observed from Task A we have not much control over the life or death of a cell in the society
built. In this task, we instead would like to take control over the life or death of every cell when we build a
society. For instance, the society built in the last sample run of Task A is replicated below:
Here, we want to model a society based on this resultant society. We shall take in this resultant society,
which consists three strings of characters, and convert it into proper internal structure of a society: List of
lists of characters of and cdots To be precise, we copy the printed society and paste it as the argument to
our modelsociety function.
Sample runs outputs are highlighted in blue for clarity:
Task C: Coding the GameOfLife Rules Marks
Our next task is to turn the set of GameofLife rules into a function. Specifically, we notice that whether a
cell will be destined to live or die depends on two factors: its current liveness: either it is alive or dead at
the moment; and the number of live neighbors surrounding it
Write a function golcellvalue, liveneigh that takes in a Boolean value representing live by True
and dead by False; and an integer between and both inclusive capturing the number of live cells in
its maximum eight neigbourhood. The function returns True when the cell will be alive in the next
evolution, and False otherwise. Your function should define correctly the gameoflife rules, as replicated
below:
Any live cell with fewer than two live neighbours dies, as if caused by loneliness.
Any live cell with two or three live neighbours lives on to the next generation, as if sustained by
friendship.
Any live cell with more than three live neighbours dies, as if caused by overcrowdedness.
Any dead cell with exactly three live neighbours becomes a live cell in the next generation, as if by
reproduction.
Sample runs:
golTrue # Current cell is alive, three live neighbor
True # The cell is destined to die in the next evolution
golFalse # Current cell is dead, three live neighbor
True # The cell is destined to live in the next evolutionTask D: Tabulating GameofLife Rules Marks
As we begin to explore different ways of defining gameoflife rules, we want to be certain about the effect
of our defined rules. A way to ascertain the effect is to display the results of the rules given the current cell
value and the number of live neighbours.
Write a function tabulaterules that takePart : Conway's GameofLife marks
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician
John Horton Conway in It is a zeroplayer game, meaning that its evolution is determined by its initial
state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and
observing how it evolves.
Wikipedia
We are interested in observing the state of a GameofLife simulation.
The simulation begins with a rectangular society of size rows, columns with any of cells
may be dead or alive. Our task is to monitor the evolution of the cells in this society for several generations
as determined by the user based on the following four GameofLife Rules:
Any live cell with fewer than two live neighbours dies, as if caused by loneliness.
Any live cell with two or three live neighbours lives on to the next generation, as if sustained by
friendship.
Any live cell with more than three live neighbours dies, as if caused by overcrowdedness.
Any dead cell with exactly three live neighbours becomes a live cell in the next generation, as if by
reproduction.
Note that cells can have up to neighbours, where a neighbour is a cell that is directly adjacent or diagonal
to the cell.
For example, given the following demography of a society here a dead cell is represented by and
a live cell is represented by respectively
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
