Skip to content
This repository
tree: ce051f4d1f
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 23 lines (21 sloc) 0.939 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
######################################################
##
## RuleR:
##
## A flexible implementation of the various
## 'wolfram rule' 1D cellular automata.
## Fun choices include 30 and 110.
##
######################################################

:const RULE 30
:const clear-color 0xFFAA99FF
:array grid-tiles 64 0xFF0000AA

: >> dup if 1 - for 2 / next else drop then ; ( a bits -- b )
: pat 0 2 for 2 * over i + @ or next swap drop ; ( addr -- pattern )
: rule pat RULE swap >> 1 and ; ( addr -- new-value )
: cell 41 * + GP @ + ; ( y x -- addr )
: get 1 - swap 1 + cell ; ( y x -- addr )
: put swap cell ! ; ( val y x -- )
: row 39 for dup i get rule over i put next ; ( y -- y )
: draw 28 for r> row >r next ;
: main 1 29 19 put draw loop sync again ;
Something went wrong with that request. Please try again.