Last active
March 24, 2020 17:04
-
-
Save JohnEarnest/db734a06be7018ac18f2e233fdb4fc51 to your computer and use it in GitHub Desktop.
Sandpile Cellular Automaton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ Sandpiles | |
/ see: https://www.youtube.com/watch?v=hBdJB-BzudU&t=0s | |
r: {y(#y)!x+!#y} / rotate y by x places | |
n: {+/(-1 1r\:x),(-1 1r/:\:x)} / orthogonal neighbor counts | |
t: {x+(-4*u)+1_+1_n@+0,+0,u:3<x} / toroidal sand collapsing | |
once: 100 100# 5 / initial board | |
tick: t / update: just collapse one iteration | |
draw: {,(;solarized;x)} / draw board as paletted pixels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment