Abelian sandpile model: Difference between revisions

Content added Content deleted
m (improved Forth solution)
m (small Forth improvement)
Line 94: Line 94:
: row<SIZE over SIZE < ensure ;
: row<SIZE over SIZE < ensure ;
: legal? col>=0 col<SIZE row>=0 row<SIZE 2drop true ;
: legal? col>=0 col<SIZE row>=0 row<SIZE 2drop true ;
: north swap 1- swap ;
: north 1. d- ;
: east 1+ ;
: east 1+ ;
: south swap 1+ swap ;
: south 1. d+ ;
: west 1- ;
: west 1- ;
: reduce peek 2dup ix dup -4 swap +! @ 4 < if dec-stack then ;
: reduce peek 2dup ix dup -4 swap +! @ 4 < if dec-stack then ;