Showing posts with label Chaos. Show all posts
Showing posts with label Chaos. Show all posts

Saturday, April 13, 2013

Cellular automation 2


# The cellular automation program was malfunctioning for a long time because I did not update the code for the New Basic 256 version .
# This is a new version where the chaotic rule and the fractal rule are used different alternating patterns.
#http://mathworld.wolfram.com/ElementaryCellularAutomaton.html

fastgraphics
graphsize 600,300
For n = 1 to 300
plot (300,1)
Print "Fractal rule every "+n+" rows"
For y = 1 to 300
For x = 1 to 600
a=0
if pixel(x-1,y)=black then a=a+1
if pixel(x,y)=black then a=a+10
if pixel(x+1,y)=black then a=a+100

if y/n = int (y/n) then
gosub fractal
else
gosub chaotic
end if

next x
refresh
next y
refresh
clg
next n

chaotic:
if a=001 or a=110 or a =010 or a=100 then plot (x,y+1)
return
fractal:
if a=001 or a=010 or a=100 then plot (x,y+1)
return

Wednesday, June 6, 2012

Cellular Automation


# This program was malfunctioning for a long time because I did not update the code to the New Basic 256 . It is very interesting to see how 2 very simple rules generate two very different patterns . One is a fractal and the other is chaotic
# You can change the rule by activating or deactivating the plotting instruction . See also http://mathworld.wolfram.com/ElementaryCellularAutomaton.html


fastgraphics
graphsize 800,400
For n = 1 to 2
plot (400,1)
For y = 1 to 400
For x = 1 to 800
a=0
if pixel(x-1,y)=black then a=a+1
if pixel(x,y)=black then a=a+10
if pixel(x+1,y)=black then a=a+100
if n=1 then gosub chaotic
if n=2 then gosub fractal
next x
refresh
next y
pause 1
clg
refresh
next n
chaotic:
if a=001 or a=110 or a =010 or a=100 then plot (x,y+1)
return
fractal:
if a=001 or a=010 or a=100 then plot (x,y+1)
return

Wednesday, December 22, 2010

Bifurcation Diagram

# http://en.wikipedia.org/wiki/Bifurcation_diagram

Graphsize 600,600
clg
fastgraphics
for c = 0 to 2 step 0.01
refresh
y=0
# Main sequence
for i=1 to 20
print "c="+c+" i="+i+" y="+y
y = y^2-c
circle 200*c,100*y+300,1
next i
next c
# graph c is the horizontal axis
for c = 0 to 600 step 40
for y = -300 to 300 step 50
text c,7,c/200
text 0,300-y,y/100
line c,0,c,600
line 0,y+300,600,y+300
next y
next c
refresh
end

Saturday, December 18, 2010

Lorenz attractor


rem http://en.wikipedia.org/wiki/Lorenz_attractor
clg
fastgraphics
graphsize 900,300
s=10
p=28
b=8/3
x=10
y=0
z=10
zoom=6
dt=0.002
for n = 1 to 100000
dx=s*(y-x)
dy=x*(p-z)-y
dz=x*y-b*z
x=x+dx*dt
y=y+dy*dt
z=z+dz*dt
plot 150+zoom*y,300-zoom*z
plot 400+zoom*x,300-zoom*z
plot 650+zoom*x,150-zoom*y
refresh
next n