Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132928 views
License: OTHER
Kernel: Python 3
from __future__ import print_function, division %matplotlib inline import numpy as np import matplotlib.pyplot as plt import thinkplot from matplotlib import rc rc('animation', html='html5')
from Life import Life, LifeViewer def make_viewer(n, m, row, col, *strings): """Makes a Life and LifeViewer object. n, m: rows and columns of the Life array row, col: upper left coordinate of the cells to be added strings: list of strings of '0' and '1' """ life = Life(n, m) life.add_cells(row, col, *strings) viewer = LifeViewer(life) return viewer
def draw(n): x = range(n) a = np.add.outer(x, x) % 2 viewer = make_viewer(n, n, 0, 0, '010', '001', '111') viewer.viewee.array[:,:] = a viewer.draw(grid=True)
draw(3)
Image in a Jupyter notebook
draw(4)
Image in a Jupyter notebook
draw(5)
Image in a Jupyter notebook
draw(6)
Image in a Jupyter notebook
draw(7)
Image in a Jupyter notebook
draw(8)
Image in a Jupyter notebook
draw(9)
Image in a Jupyter notebook
draw(10)
Image in a Jupyter notebook
draw(11)
Image in a Jupyter notebook
draw(12)
Image in a Jupyter notebook
draw(13)
Image in a Jupyter notebook