In [2]:
import numpy as np
import theano
import theano.tensor as T
In [14]:
# Uncomment and run this cell for one solution
load ./spoilers/logistic.py
In [31]:
# Uncomment and run this cell for one solution
#%load spoilers/fib.py
Implement Conway's Game of Life with periodic boundary conditions (wrapping borders).
In [34]:
board = theano.shared(np.zeros((100, 100), dtype='uint8'))
initial = np.random.binomial(1, 0.1, size=(100, 100)).astype('uint8')
board.set_value(initial)
In [ ]:
# Create a function f that updates board with new values and return the current state
# Uncomment the line below and run for a solution
#%load spoilers/life.py
In [44]:
# After creating your f function, run this cell to animate the output
%matplotlib notebook
import matplotlib.pyplot as plt
from IPython import display
import time
for i in range(50):
plt.gca().cla()
current = f()
plt.imshow(current, interpolation='nearest', cmap='gray')
display.clear_output(wait=True)
display.display(plt.gcf())
time.sleep(0.1)