rule110.py

Created by alain-busser

Created on April 26, 2018

525 Bytes

rule 110 (in Wolfram’s notation) for a one dimensional cellular automaton . Proved to be Turing-complete by Matthew Cook. To run an experiment, just init(); screen()


from kandinsky import *
from random import *
b=color(0,0,0)
w=color(255,255,255)
def alive(x,y):
  if x==0 or x==320: return False
  elif get_pixel(x-1,y-1) and not get_pixel(x,y-1) and not get_pixel(x+1,y-1): return True
  else: return get_pixel(x-1,y-1)==get_pixel(x,y-1)==get_pixel(x+1,y-1)
def init():
  for x in range(320): set_pixel(x,0,b)
  for n in range(10):
    set_pixel(randrange(320),0,w)
def screen():
  for y in range(1,240):
    for x in range(320):
      if alive(x,y): set_pixel(x,y,b)