One-dimensional cellular automata: Difference between revisions

Added Applesoft BASIC, Chipmunk Basic, GW-BASIC, MSX Basic and Quite BASIC
(Added Applesoft BASIC, Chipmunk Basic, GW-BASIC, MSX Basic and Quite BASIC)
Line 660:
Generation 8 : __##________________
Generation 9 : __##________________</pre>
 
==={{header|Applesoft BASIC}}===
{{trans|Locomotive BASIC}}
<syntaxhighlight lang="qbasic">100 HOME
110 n = 10
120 READ w : DIM x(w+1),x2(w+1) : FOR i = 1 TO w : READ x(i) : NEXT
130 FOR k = 1 TO n
140 FOR j = 1 TO w
150 IF x(j) THEN PRINT "#";
155 IF NOT x(j) THEN PRINT "_";
160 IF x(j-1)+x(j)+x(j+1) = 2 THEN x2(j) = 1
165 IF x(j-1)+x(j)+x(j+1) <> 2 THEN x2(j) = 0
170 NEXT : PRINT
180 FOR j = 1 TO w : x(j) = x2(j) : NEXT
190 NEXT
200 DATA 20,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|BASICA}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
{{works with|QuickBasic}}
{{works with|Quite BASIC}}
<syntaxhighlight lang="qbasic">100 CLS
110 LET n = 10
120 READ w
121 DIM x(w+1): DIM x2(w+1)
122 FOR i = 1 TO w : READ x(i) : NEXT i
130 FOR k = 1 TO n
140 FOR j = 1 TO w
150 IF x(j) THEN PRINT "#"; ELSE PRINT "_";
160 IF x(j-1)+x(j)+x(j+1) = 2 THEN LET x2(j) = 1 ELSE LET x2(j) = 0
170 NEXT j
171 PRINT
180 FOR j = 1 TO w : LET x(j) = x2(j) : NEXT j
190 NEXT k
200 DATA 20,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0
210 END</syntaxhighlight>
 
==={{header|FreeBASIC}}===
Line 705 ⟶ 746:
loop
wend</syntaxhighlight>
 
==={{header|GW-BASIC}}===
The [[#Chipmunk Basic|Chipmunk Basic]] solution works without any changes.
 
==={{header|MSX Basic}}===
The [[#Chipmunk Basic|Chipmunk Basic]] solution works without any changes.
 
==={{header|Quite BASIC}}===
The [[#Chipmunk Basic|Chipmunk Basic]] solution works without any changes.
 
==={{header|Run BASIC}}===
The [[#Liberty BASIC|Liberty BASIC]] solution works without any changes.
 
==={{header|Sinclair ZX81 BASIC}}===
2,122

edits