from kandinsky import draw_string from random import randint a = 18 #222//12 b = 26 #320//12 A = range(a) B = range(b) Liste = [[0 for col in B] for lig in A] for lig in A: for col in B: Liste[lig][col] = randint(0,1) if Liste[lig][col] == 1: draw_string(chr(215),12*col+3,12*lig+2,'blue') Nouv = [[0 for col in B] for lig in A] for gen in range(50): for i in A: for j in B: Voisins = 0 for k in [-1,0,1]: for l in [-1,0,1]: if [k,l] != [0,0]: Voisins += Liste[(i+k)%a][(j+l)%b] Nouv[i][j] = 0 couleur = 'white' if Voisins == 3 or ( Liste[i][j] == 1 and Voisins == 2 ): Nouv[i][j] = 1 couleur = 'blue' if Nouv[i][j]+Liste[i][j] > 0: draw_string(chr(215),12*j+3,12*i+2,couleur) Liste = [[Nouv[m][n] for n in B] for m in A]