I found 'xsand.c' (X11) in 1995 by Michael Creutz, that simulated these sandpiles; I had fun with the sand but also learned C from it.