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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.