One-dimensional cellular automata: Difference between revisions
Content added Content deleted
({{header|PureBasic}}) |
m (→{{header|PureBasic}}: beautify code and Output) |
||
Line 1,158:
OpenConsole()
Repeat
Print("Generation "+Str(Gen)+": ")▼
For n=1 To 20▼
▲Print("Generation "+Str(Gen)+":")
▲For n=1 To 20
Next▼
▲ Print(Str(cG(n)))
Gen +1▼
▲Next
PrintN("")▼
▲Gen +1
For n=1 To 20▼
▲PrintN("")
If (cG(n)= 1 And (cG(n-1)+cg(n+1)=1)) Or (cG(n)= 0 And (cG(n-1)+cg(n+1)=2))▼
▲For n=1 To 20
nG(n)=1
▲ If (cG(n)= 1 And (cG(n-1)+cg(n+1)=1)) Or (cG(n)= 0 And (cG(n-1)+cg(n+1)=2))
nG(n)=0
EndIf
Swap cG() , nG()▼
▲Swap cG() , nG()
Until Gen > 9
PrintN("Press any key to exit"): Repeat: Until Inkey() <> ""</lang>Output:
<pre>Generation 0: ### ## # # # # #
Generation
Generation
Generation
Generation
Generation
Generation
Generation
Generation
Press any key to exit</pre>
|