import time import random import numpy as np x = int(input("Size:")) state = [] new = [] for i in range(x): state.append(0) new.append(0) state[int(x/2)] = 1 step = 0 while True: r = random.randint(0,5) if (r == -1): state[int(x/2)] = 1 for i in range(len(state)): if (state[i] == 1): print("\033[1;42m"+" ",end="") else: print("\033[1;40m"+" ",end="") print() time.sleep(0.05) for i in range(1,x-1): if (state[i-1] == 1 and state[i] == 0 and state[i+1] == 0): new[i] = 1 if (state[i-1] == 0 and state[i] == 1 and state[i+1] == 0): new[i] = 1 if (state[i-1] == 0 and state[i] == 0 and state[i+1] == 1): new[i] = 1 if (state[i-1] == 0 and state[i] == 1 and state[i+1] == 0): new[i] = 1 for i in range(1,x-1): state[i] = new[i] new[i] = 0 step += 1