See live example
source: gist.github.com/gists/1320456
Seth Tisue wrote Bureaucrats-fast a simplified re-write of this model written by Bob Tinker Bureaucrats.v6 exploring Self-Organised Criticality
The mathematics of avalanche size and frequency follows a power law that can be simulated to a first approximation by any system that exhibits self-organized criticality (SOC). In "How Nature Works"" Per Bak reports a simplified model of a sandpile that he, Chao Tang, and Curt Wiesenfeld developed that shows SOC, the so-called BTW model. Bak also mentions that Grassberger describes a representation of this model that is fanciful but equivalent to the BTW model. Imagine an N-by-N grid of office desks and a bureaucrat sitting at each. A folder is randomly assigned to one desk. The bureaucrat does nothing until four or more folders are on his desk at which time he sends one to each of his four nearest neighbors. Any bureaucrat sitting at the edge of this array throws a folder out the window if there is no desk to send it to. Sometimes, adding one folder can cause multiple redistributions of folders as one bureaucrat's actions causes neighbors to exceed three folders, which then ripples through the office. In principle, just adding one new folder might involve redistribution at every desk, sometimes multiple times.