aUCBLogo Demos and Tests / ideal_gas
to ideal_gas
; norefresh
cs ht
setUpdateGraph false
setScreenColor 0
n=1000
x=Array n
ox=Array n
v=Array n
c=Array n
repeat n
[ x.repcount=List 20*(rnd-0.5) 20*(rnd-0.5)
v.repcount=List 2*(rnd-0.5) 2*(rnd-0.5)
c.repcount=hsb 360*repcount/n 0.7 1
]
ox=x+0 ; to create the same structure as in x, so that we can use xcopy and x+=v
i=0
t=0
spur=false
pr [SPACE toggles cleaning]
forever
[; t0=timefine
if key?
[ ch=readchar
if ch==char 27 [stop]
if ch=="\ [spur=not spur]
]
xcopy "ox x ; copy only the values (no new nodes are made)
x+=v ; dito
repeat n
[ if (maxnorm x.repcount) > 290
[ if (abs first x.repcount) > 290
[ _setFirst v.repcount -(first v.repcount)
]
if (abs first bf x.repcount) > 290
[ _setFirst bf v.repcount -(last v.repcount)
]
]
]
if not spur [clean]
setPixel x c
updateGraph
gc
; t = (i*t + timefine-t0)/(i+1)
; ct (pr 1/t "frames/sec)
; i+=1
]
end