Version en 10x10. Version en 5x5 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(32) h = range(22) 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*10,y*10+1,10,10,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]<=31 and 0<=y+couple[1]<=21: 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*10,y*10+1,10,10,M2[y][x] and (0,)*3 or (255,)*3) for y in h: for x in w: M1[y][x] = M2[y][x] conway()