Forked from /alain-busser/rule110: https://my.numworks.com/python/alain-busser/rule110
from kandinsky import * from random import * B=color(0,0,0) W=color(255,255,255) # Screen SW=320 SH=222 def Alive(x,y): if x==0 or x==SW: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(): # Generate the first line randomly fill_rect(0,0,SW,1,B) for n in range(10):set_pixel(randrange(SW),0,W) def Screen(): # First entire screen fill for y in range(1,SH): for x in range(SW): if Alive(x,y):set_pixel(x,y,B) while True: # Shifting every line 1 pixel up for y in range(1,SH): for x in range(SW): set_pixel(x,y-1,get_pixel(x,y)) # Gen new last line y=SH-1 fill_rect(0,y,SW,1,W) for x in range(SW): if Alive(x,y):set_pixel(x,y,B) Init() Screen()