tr(v)=if (v>=0, 1+2*v, -2*v) big = 100000 s = [] S = [] seen(z)=my (x=tr(real(z)),y=tr(imag(z)));if (max(x,y)>big, setsearch(S,z), x>#s, 0, bittest(s[x],y)) see(z)=my (x=tr(real(z)),y=tr(imag(z)));if (max(x,y)>big, S=setunion(S,Set(z)); return, x>#s, s=concat(s,vector(x-#s))); s[x]=bitor(s[x],2^y) \\ translate a tile move(t, dz) = { apply (z -> z+dz, t); } DX = 4-I DY = 6*I \\ we have 6 tiles: 4 horizontal, 2 vertical H = [0, 1, 3, 4] V = I*H T = vector(6) T[1] = move(H, 0) \\ red T[2] = move(H, 2*I-1) \\ blue T[3] = move(H, 3*I) \\ blue T[4] = move(H, 5*I-1) \\ red T[5] = move(V, 1+I) \\ green T[6] = move(V, 2) \\ green for (t=1, #T, T[t] = Set(T[t])) \\ neighbourhood neighbourhood(t) = { setminus( Set(concat(apply( z -> move(powers(I,3), z), t ))), Set(t) ); } \\ connections [t', dz] C = vector(#T, t, []) { for (t=1, #T, dt = neighbourhood(T[t]); for (dx=-1, +1, for (dy=-1, +1, dz = dx + dy*I; DZ = dx*DX + dy*DY; for (o=1, #T, if (#setintersect(dt, move(T[o], DZ)), C[t] = concat(C[t], [[o, dz]]); ); ); ); ); ); } \\ compute coordination sequence encode(t, dz) = { (t-1) + real(dz)*#T + imag(dz)*I } decode(z) = { [ 1 + (real(z) % #T), real(z) \ #T + imag(z) * I ] } { gen = [encode(6, 0)]; newgen = [0]; for (n=0, N=1000, print (n " " #gen); if (n #newgen, newgen = concat(newgen, vector(#newgen)); ); newgen[nb] = nxt; ); ); ); gen = Set(newgen[1..nb]); ); ); } quit