La fourmi de Langton, n est le nombre de pas de la fourmi.
import kandinsky def langton(n): d=0 x,y=159,111 e=((0,1),(-1,0),(0,-1),(1,0)) for _ in range(n): if kandinsky.get_pixel(x,y)!=(0,0,0): d-=1 kandinsky.set_pixel(x,y,(0,0,0)) else: d+=1 kandinsky.set_pixel(x,y,(255,255,255)) d%=4 x+=e[d][0] y+=e[d][1] x%=320 y%=222