Version en 5x5. Version en 10x10 dispo ici
from kandinsky import fill_rect from ion import keydown from random import randint def conway(): couples = [[x,y] for x in [-1,0,1] for y in [-1,0,1] if (x,y) != (0,0)] w = range(64) h = range(44) M1 = [[0 for j in w] for i in h] M2 = [[0 for j in w] for i in h] for y in h: for x in w: M1[y][x] = randint(0,1) fill_rect(x*5,y*5+1,5,5,M1[y][x] and (0,)*3 or (255,)*3) while not keydown(1): for y in h: for x in w: somme = 0 for couple in couples: if 0<=x+couple[0]<=63 and 0<=y+couple[1]<=43: somme += M1[y+couple[1]][x+couple[0]] M2[y][x] = somme == 3 or M1[y][x] and somme == 2 if M2[y][x] != M1[y][x]: fill_rect(x*5,y*5+1,5,5,M2[y][x] and (0,)*3 or (255,)*3) for y in h: for x in w: M1[y][x] = M2[y][x] conway()