Question
Conway's Game of Life Now that we have a working evolve function, we can carry out longer-term simulations of the Game of Life. (If you
Conway's Game of Life
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:
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()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started