from kandinsky import draw_string, fill_rect from random import choice, randint from time import sleep RO, BL, NR, VE = (248,0,0), (40,160,216), (0,0,0), (0,255,0) # les etats de l'automate data = [[randint(0,9), BL] for i in range(16 * 32)] # ecran noir fill_rect(0,0,320,222,NR) while True: # case qui va etre changee n = randint(0, 16 * 32 - 1) if data[n][0] != 8: v = max(0,min(data[n][0] + choice([-1,1]), 9)) data[n][0] = v data[n][1] = choice([BL,RO]) if v != 8 else VE draw_string(str(v), 10 * (n % 32), -2 + 15 * (n // 32), data[n][1], NR) sleep(.005)