RosettaCodeData/Task/One-dimensional-cellular-automata/BBC-BASIC/one-dimensional-cellular-automata.basic
2023-07-01 13:44:08 -04:00

13 lines
381 B
Text

DIM rule$(7)
rule$() = "0", "0", "0", "1", "0", "1", "1", "0"
now$ = "01110110101010100100"
FOR generation% = 0 TO 9
PRINT "Generation " ; generation% ":", now$
next$ = ""
FOR cell% = 1 TO LEN(now$)
next$ += rule$(EVAL("%"+MID$("0"+now$+"0", cell%, 3)))
NEXT cell%
SWAP now$, next$
NEXT generation%