Question: (this is the first question and I need to fill in the blanksin the starter code): Consider a wrapper loop that will simulate a glider

(this is the first question and I need to fill in the blanksin the starter code):

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

import numpy as np import matplotlib.pyplot as plt glider = np.zeros( ( 24,24 ) ) glider[ 10,10 ] = 1 glider[ 11,10 ] = 1 glider[ 12,10 ] = 1 glider[ 12,11 ] = 1 glider[ 11,12 ] = 1 nt = 10 for t in range( nt ): cells = evolve( cells ) plt.imshow( cells ) plt.show() 

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.

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 

Your submission for this part should include the list of ndarrays named pd_list. If you wish to see the results at each time step, move plt.show() into the loop.

Starter code (click to view)

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 = ??? nt = 30 for t in ???: ??? # evolve the simulation and append it to `pd_list` plt.imshow( pd_list[ -1 ] ) plt.show() 

(This is part two and the first code must be solved in order to to solve this code. I need to the same as the first code, fill in the blanks in the started code given below ):

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.

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 

Your submission for this part should include the ndarray named pd_time.

After you have completed this step, try simulating other shapes and see what you can find out about the behavior of this complex system arising from simple rules.

Starter code (click to view)

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 = ??? evoln = pentadecathlon[ : ] nt = 30 for t in ???: ??? # evolve the system forward in `evoln` pd_time += evoln plt.imshow( pd_time ) plt.show() 

(Conway's Game of Life)!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!