Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Current Question Finally, we will model how the game evolves over time in a sing

ID: 3698733 • Letter: C

Question

Current Question

Finally, we will model how the game evolves over time in a single plot.

Modify your code from the previous step. Instead of storing the time steps as separate elements in a list, each time step should be added to an accumulator array pd_time. This will give us a "heat map" of how the system has evolved over time. Use pentadecathlon again.

Starter Code

Previous Question for reference

Now that we have a working evolve function, we can carry out longer-term simulations of the Game of Life. (If you haven't gotten evolve to work yet, we provide it for this step.)

Consider a wrapper loop that will simulate a glider traveling for nt time steps:

Write a program which implements a loop evolving pentadecathlon for thirty time steps. You should implement a list of ndarrays named pd_list, each containing a single generation of pentadecathlon's evolution.

import numpy as np
import matplotlib.pyplot as plt

pentadecathlon = np.zeros( ( 24,24 ) )
pentadecathlon[ 10:20,10 ] = 1
pentadecathlon[ 12, 9 ] = 1
pentadecathlon[ 12,10 ] = 0
pentadecathlon[ 12,11 ] = 1
pentadecathlon[ 17, 9 ] = 1
pentadecathlon[ 17,10 ] = 0
pentadecathlon[ 17,11 ] = 1

pd_list = []
pd_list.append( pentadecathlon )
nt = 30
for t in range(nt):
pentadecathlon = evolve ( pentadecathlon )
pd_list.append( pentadecathlon ) # evolve the simulation and append it to `pd_list`
plt.imshow( pd_list[ -1 ] )
plt.show()

Explanation / Answer

1.
import numpy as np
import matplotlib.pyplot as plt

pentadecathlon = np.zeros( ( 24,24 ) )
pentadecathlon[ 10:20,10 ] = 1
pentadecathlon[ 12, 9 ] = 1
pentadecathlon[ 12,10 ] = 0
pentadecathlon[ 12,11 ] = 1
pentadecathlon[ 17, 9 ] = 1
pentadecathlon[ 17,10 ] = 0
pentadecathlon[ 17,11 ] = 1

pd_time = np.zeros((24,24))
evoln = pentadecathlon[ : ]
nt = 30
for t in range(nt):
    evoln = evolve(evoln)    # evolve the system forward in `evoln`
    pd_time += evoln
plt.imshow( pd_time )
plt.show()


2.

import numpy as np
import matplotlib.pyplot as plt

pentadecathlon = np.zeros( ( 24,24 ) )
pentadecathlon[ 10:20,10 ] = 1
pentadecathlon[ 12, 9 ] = 1
pentadecathlon[ 12,10 ] = 0
pentadecathlon[ 12,11 ] = 1
pentadecathlon[ 17, 9 ] = 1
pentadecathlon[ 17,10 ] = 0
pentadecathlon[ 17,11 ] = 1

pd_list = [pentadecathlon]
nt = 30
for t in range(0,nt ):
    evolved = evolve(pd_list[-1])     # evolve the simulation and append it to `pd_list`
    pd_list.append(evolved)
    plt.imshow( pd_list[ -1 ] )
plt.show()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote