aUCBLogo Demos and Tests / ant2
be ant2
cs ht
t=timefine
start=100
finish=200
d=finish
field=mdArray list d d
n=20000
antx=(start+finish)/2
anty=(start+finish)/2
jump=5
stepcount=0
framedelay=20
; setactivearea [-260 -260 260 260]
append=false
for [a 1 n]
[ ifelse (or antx<start anty<start antx>finish anty>finish)
[ print [ant went be far]
(pr timefine-t "sec)
stop
]
[move]
if (mod a 20)==0
[ updateGraph
]
]
(pr timefine-t "sec)
be move
ifelse (field.antx).anty==0
[ setfc 0
square jump
rt 90 fd jump
setitem anty field.antx 1
][ setfc 7
square jump
lt 90 fd jump
setItem anty field.antx 0
]
ifelse or heading==90 heading==270
[ ifelse heading==90
[ antx=antx+1
][ antx=antx-1
]
][ ifelse heading==0
[ anty=anty+1
][ anty=anty-1
]
]
end
be square size
pd
local [sh]
sh=size/2+0.5
fillRect list -sh -sh list sh sh
penup
stepcount=stepcount+1
; if stepcount==framedelay
; [ (gifsave "ant.gif 0 append 0)
; stepcount=0
; append=true
; ]
end
end