import numpy as np from PIL import Image, ImageDraw, ImageFont N=104;y,x=np.indices((N,N))-N//2 axis,diag=np.maximum(abs(x),abs(y)),np.minimum(abs(x),abs(y)) cy,cx=(N//2-diag)%N,(N//2-axis)%N m=x*x+y*y<=9;u,v=np.where(m,.55,1.),np.where(m,.30,0.) def lap(a): return np.roll(a,1,-1)+np.roll(a,-1,-1)+np.roll(a,1,-2)+np.roll(a,-1,-2)-4*a def step(u,v): R=u*v*v return u+.16*lap(u)-R+.028*(1-u),v+.08*lap(v)+R-.09*v for _ in range(4800): a,b=step(u,v);u,v=a[cy,cx],b[cy,cx] u,v=np.stack((u,u)),np.stack((v,v)) v[1]+=1e-6*np.exp(-(x*x+y*y)/8)*(x*x-y*y)/4 palette=np.array([[22,25,36],[32,52,85],[94,82,112],[175,111,104],[235,166,118],[255,235,182]]) font=lambda n:ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf',n) ink='#352b30'; im=Image.new('RGB',(950,568),'#f7efdf');d=ImageDraw.Draw(im) d.text((23,15),'A spot that looks settled',font=font(34),fill=ink) d.text((24,65),'Starting from the same compact spot, with or without a tiny directional nudge',font=font(17),fill=ink) for i in range(2251): if i in (0,1000,1500,2250): j=(0,1000,1500,2250).index(i); xx=141+197*j d.text((xx,110),f'{i:,} steps',font=font(18),fill=ink) for k in (0,1): yy=141+199*k a=v[k,22:82,22:82] rgb=np.uint8(np.stack([np.interp(a,np.linspace(0,.40,6),palette[:,l]) for l in range(3)],-1)) im.paste(Image.fromarray(rgb).resize((181,181),Image.Resampling.BILINEAR),(xx,yy)) print(i,(v>.12).sum(axis=(1,2)),v.max(axis=(1,2))) a,b=step(u,v);u,v=a,b;u[0],v[0]=a[0,cy,cx],b[0,cy,cx] d.text((24,216),'Symmetry\npreserved',font=font(16),fill=ink) d.text((24,415),'Nudged',font=font(16),fill=ink) d.text((24,540),'Same four-neighbor update and color scale; each view crops the center to 60 × 60 cells.',font=font(15),fill=ink) im.save('delayed.png')