Codรฉ par Kevin Fedyna, colorรฉ.
# par Kevin Fedyna from kandinsky import fill_rect from ion import keydown from random import randint try: get_keys() os = (192,53,53) except: os = (255,183,52) 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+1,y*10+2,10,10,M1[y][x] and os 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+1,y*10+2,10,10,M2[y][x] and os or (255,)*3) for y in h: for x in w: M1[y][x] = M2[y][x] conway()