In [1]:
import rules
import utils
import update
import neighborhood
import numpy
In [45]:
# generate initial state of 200 boolean values (0..2 excluding 2, thus 0 or 1)
state0 = numpy.random.randint(0,2,400).astype(bool)
# create a neighborhood of 1 (left, center, right) which wraps around edges
n1_wrap = neighborhood.nx_generator(1, wrap=True)
# run Wolfram's rule 110 on the initial state.
# this will also create a matplotlib space-time graph.
result = update.evolve(100, state0, n1_wrap, rules.wolfram(110))
In [47]:
# generate initial state of 200 boolean values (0..2 excluding 2, thus 0 or 1)
state0 = numpy.random.randint(0,2,400).astype(bool)
# create a neighborhood of 1 (left, center, right) which wraps around edges
n1_wrap = neighborhood.nx_generator(1, wrap=True)
# run Wolfram's rule 110 on the initial state.
# this will also create a matplotlib space-time graph.
In [48]:
%%time
result = update.evolve(200, state0, n1_wrap, rules.wolfram(110),plot=None)
result.shape
In [49]:
result.shape
Out[49]:
In [50]:
from IPython.display import display,clear_output
from PIL import Image as Im
import time
import numpy as np
In [51]:
Ni,Nj = result.shape
scale = 2
display(Im.fromarray(240*result.astype(np.uint8)).resize((scale*Nj,scale*Ni)) )
In [ ]: