A sandpile is a $n \times n$ grid $A$ where each element $A[i][j]$ is an integer in the range $[0, 6]$. A toppling of a sandpile happens if an element of $A$ has value $\ge 4$. If there is such an element $A[i][j]$, we perform the following steps:
- Decrease $A[i][j]$'s value by 4.
- Increment all (up to 4) neighboring elements that are in the grid by 1. If $A[i][j]$ is on the "edge" of the grid, ignore the indices that are not in $A$.
For example, if we have:
$\begin{pmatrix} 6 & 3\\ 2 & 2 \end{pmatrix}$
Then we "spill" the first row, first column element:
$\begin{pmatrix} 2 & 4\\ 3 & 2 \end{pmatrix}$
Since there is another element with value at least 4, we spill again:
$\begin{pmatrix} 3 & 0\\ 3 & 3 \end{pmatrix}$
Now, we stop. The number of rounds in a given matrix, $S(A)$, is the number of topplings performed. We assume that if an element is found with value at least 4, we perform all other topplings of the matrix in the same "round" (i.e., one scan of the matrix to find values at least 4, and performing topplings in the process, is a "round"). For a given value of $n$, I want to find the matrix for which the number of topplings is maximum.
For example, for $n=2$ the matrix that yields $S(2) = 8$ is:
$\begin{pmatrix} 6 & 5\\ 5 & 5 \end{pmatrix}$.
For $n=3$ the matrix that yields $S(3) = 33$ is:
$\begin{pmatrix} 6 & 5 & 6\\ 6 & 6 & 5\\ 6 & 6 & 6 \end{pmatrix}$.
For $n = 4$, this is $S(4) = 82$:
$\begin{pmatrix} 6 & 5 & 6 & 5\\ 6 & 6 & 6 & 6\\ 6 & 6 & 6 & 6\\ 6 & 6 & 6 & 5 \end{pmatrix}$
Is there a characterization of which matrices give the largest number? It is clear that all the entries have to be 5 or 6, but I do not know an algorithm (other than brute force) to find such a matrix (or the number). Also, OEIS does not have the given examples in any sequence.