\datethis @s class ident @*Intro. Simple playing with sandpiles on the $3\times$3 torus. @d space (1<<16) @c #include int link[8][space], cyc[8][space], class[space], next[space]; int rec[space], hit[space]; int classes,recs; int x[9]; int v[9][9]={ {4,-1,-1,-1,0,0,-1,0,0}, {-1,4,-1,0,-1,0,0,-1,0}, {-1,-1,4,0,0,-1,0,0,-1},@| {-1,0,0,4,-1,-1,-1,0,0}, {0,-1,0,-1,4,-1,0,-1,0}, {0,0,-1,-1,-1,4,0,0,-1},@| {-1,0,0,-1,0,0,4,-1,-1}, {0,-1,0,0,-1,0,-1,4,-1}, {0,0,-1,0,0,-1,-1,-1,4}}; @@; main() { register int j,k,t,y; @; @; @; @; } @ @= void reduce() { register int g,j,k; for (g=0,j=1;g<8;j=(j&7)+1) { if (x[j]<4) g++; else { for (k=1;k<=8;k++) x[k]-=v[j][k]; g=0; } } } @ In the first experiment, I add a grain of sand and look at the resulting functional digraph. Beware: There's a serious bug in this logic, which makes the results of experiment~1 pretty much meaningless. @= for (y=0;y<8;y++) { for (k=0;k>=2; x[y+1]++; reduce(); for (t=x[1],j=2;j<=8;j++) t=(t<<2)+x[j]; link[y][k]=t; } for (k=0;k; @ @= for (k=0;k= void yunion(int j, int k) { register int i,ii; if (class[j]!=class[k]) { for (i=j;class[i]!=class[k];ii=i,i=next[i]) class[i]=class[k]; next[ii]=next[k], next[k]=j, classes--; } } @ @= for (k=0;k>=2; x[1]++, x[2]++, x[3]++, x[6]++; reduce(); for (t=x[1],j=2;j<=8;j++) t=(t<<2)+x[j]; yunion(k,t); } printf("Identifying equivalent states leads to %d classes.\n",classes); @; @ @= printf("The zero class contains the following members:\n 0000"); for (k=next[0];k;k=next[k]) printf(" %04x",k); printf("\n"); @ @= loop:@+for (k=0;k= printf("The minimal ones are:\n"); for (t=k=0;k