OFFSET
1,2
COMMENTS
The Abelian sandpile model is a cellular automaton considering the behavior of sand grains on a square grid. Any square containing 4 or more grains will topple, sending a grain to each of its 4 neighbors and subtracting 4 grains from itself.
Here, expansion refers to the addition of a boundary layer to the outside of the existing matrix when the model reaches beyond the previous matrix boundary.
EXAMPLE
_ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ |0|0|1|0|0|
_ |0|1|0| |0|2|0| |0|3|0| |0|4|0| |0|2|1|2|0|
|∞| -> |1|∞|1| -> |2|∞|2| -> |3|∞|3| -> |4|∞|4| -> |1|1|∞|1|1| -> ...
‾ |0|1|0| |0|2|0| |0|3|0| |0|4|0| |0|2|1|2|0|
‾ ‾ ‾ ‾ ‾ ‾ ‾ ‾ ‾ ‾ ‾ ‾ |0|0|1|0|0|
‾ ‾ ‾ ‾ ‾
^ ^
1st expansion on 2nd expansion on
1st iteration (a(1) = 1) 5th iteration (a(2) = 5)
PROG
(MATLAB)
L = 3;
plane = zeros(3, 3);
plane(2, 2) = 99999999999999999999999999999999999999999999999;
listn = [];
for n = 1:50000
plane2 = plane;
for r = 1:L
for c = 1:L
if plane(r, c) > 3
plane2(r, c) = plane2(r, c) - 4;
plane2(r-1, c) = plane2(r-1, c)+1;
plane2(r+1, c) = plane2(r+1, c)+1;
plane2(r, c-1) = plane2(r, c-1)+1;
plane2(r, c+1) = plane2(r, c+1)+1;
end
end
end
if sum(plane2(:, 1))+sum(plane2(1, :)) > 0
plane2 = padarray(plane2, [1, 1]);
L = L+2;
listn = [listn n];
end
plane = plane2;
end
fprintf('%s\n', sprintf('%d, ', listn))
(PARI)
Step(M)={my(n=#M, R=matrix(n, n)); for(i=2, n-1, for(j=2, n-1, if(M[i, j]>=4, R[i, j]-=4; R[i, j+1]++; R[i, j-1]++; R[i-1, j]++; R[i+1, j]++))); M+R}
Expand(M)={my(n=#M, R=matrix(n+2, n+2)); for(i=1, n, for(j=1, n, R[i+1, j+1]=M[i, j])); R}
seq(n)={my(L=List(), M=matrix(3, 3), k=0); while(#L<n, k++; my(o=#L+2); M[o, o]=4; M=Step(M); if(M[1, ], M=Expand(M); listput(L, k))); Vec(L)} \\ Andrew Howroyd, Oct 23 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Parker Grootenhuis, Oct 22 2019
STATUS
approved