Rows | |

Columns | |

Geometry | |

Rows | |

Columns | |

Geometry | |

- Cells are
*editable*meaning that you can change the number of grains by clicking and typing. - Set the number of rows and columns to set the grid size.
- Select the geometry to decide what happens on the boundary.
- Click Topple to topple every unstable cell.
- Click Reset to reset every cell to zero.

This webpage provides a sandbox to play with sandpiles. Sandpiles were the 90th activity in Annie Perkins' Math Art Challenge.

In a sandpile, each cell has a certain number of grains of sand
in it.
A cell is *unstable* if it has more than three grains
(more generally, at least as many grains as neighbours).
An unstable cell can *topple*, whereupon it gives one
grain to each of its neighbours.

This implementation is slightly different to how sandpiles work in the literature as I slightly misunderstood the instructions. In the literature, a "turn" consists of a single cell toppling. Although on a given turn there is a choice, in the long run then the order of choices doesn't matter.

In my version, however, on a given turn then *every* cell
that is currently unstable topples.
This can lead to a different type of long term behaviour.
In particular, it makes sense to consider *periodic* long
term behaviour.

With pretty much anything mathematical on a grid I find myself asking "What does this look like on a torus?", shortly followed by a Klein bottle and a projective plane. This determines what happens when cells on the edge topple. The options are:

- Soft: grains that fall off the edge disappear.
- Hard: grains that should fall off the edge stay in their original cell.
- Torus: grains that should fall off the edge disappear reappear on the opposite side.
- Klein: grains that should fall off the edge disappear reappear on the opposite side, but the top and bottom edges are reflected.
- Projective plane: grains that should fall off the edge disappear reappear on the opposite side, but both pairs of edges are reflected.