|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false2 J4 O: t6 D: k5 s4 ?* u
to go6 m! S3 p' u$ Q
if not any? turtles with [not stopped? ] [ stop ]
6 D: X- O6 Q- U# }8 C" e! V# Nask turtles with [remainder who 5 = 0] [
& Q6 X/ w, w5 E' x) T# iset close-mates (turtles with [self != myself])with[
W" P% Z1 q# u6 a(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) * l) D* Y' P* e6 I
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
' X; B: A7 z9 W) h5 a! zand remainder who 5 = 0 1 p" E) y3 d( O3 k
]
, J' I q g5 rifelse any? close-mates
# j- O3 w2 o/ C[ 3 D0 _& c) M+ V! T7 \, N- p- i6 O# T
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 \+ o/ ^9 J9 N Q" G2 H# g2 ~& I: Oface closest-one
! s1 K; V7 n/ Xrt 180* ?, F% o3 Q7 g7 O/ l
fd random-float step-size
6 m7 v! t j" m0 Y' aavoid-walls
. e3 m; F2 S8 N$ Fset stopped? false]! B4 M! O3 _6 N9 _* C
[set stopped? true] $ _$ D8 {* J4 m" K6 ?
] |
|