Anonymous user
One-dimensional cellular automata: Difference between revisions
One-dimensional cellular automata (view source)
Revision as of 20:53, 10 February 2017
, 7 years ago→{{header|Liberty BASIC}}
Line 2,624:
<lang lb>' [RC] 'One-dimensional cellular automata'
' does not wrap so fails for some rules
rule$ ="00010110" ' Rule 22 decimal
Line 2,632 ⟶ 2,630:
for j =1 to 20
print state$▼
oldState$ =state$
state$ ="0"
for k =2 to
NHood$ =mid$( oldState$, k -1, 3) ' pick 3 char neighbourhood and turn binary string to decimal
vNHood =0
Line 2,643 ⟶ 2,642:
state$ =state$ +mid$( rule$, vNHood +1, 1)
next k
state$ =state$ +"0"
▲ print state$
next j
|