|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ _- s! f6 J4 ], ]2 I. v; {/ E
to go
* _$ x+ @- O+ O- Cif not any? turtles with [not stopped? ] [ stop ] 1 f s% O# K8 C, H: U
ask turtles with [remainder who 5 = 0] [, s5 b1 r; P+ Y* b
set close-mates (turtles with [self != myself])with[
+ t# N0 b7 A, E% t1 ^6 N(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) " {+ h) J$ Y- A! J
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % g6 g4 _* h1 F
and remainder who 5 = 0 ; D _& b: F6 R: e: Y) p# D
]
# C! @% U7 l+ `3 g( Nifelse any? close-mates * W/ S/ M& a$ B- V9 O% }
[
' \0 \' r* E) a yset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
7 v2 Q9 q$ T& [' o; V( uface closest-one% ~4 \1 b2 Y/ I0 ^$ B5 _' G
rt 180
# }: i) U" F' Y# w9 W3 W! Nfd random-float step-size
2 t) I) c. E# r& |8 X) yavoid-walls7 @7 t! g3 ]% M# h1 n1 k/ c6 P
set stopped? false]2 o0 T2 N3 _. w0 `
[set stopped? true]
! O: {; Q4 O+ E1 \* V0 p] |
|