|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false- c8 l$ H) b! ?. ]7 {
to go
8 v. k1 `) J$ K% p8 v' g/ bif not any? turtles with [not stopped? ] [ stop ] 2 F2 m f; _6 Z2 v5 t9 V7 D( y( T
ask turtles with [remainder who 5 = 0] [ z/ r8 m% g) s' s
set close-mates (turtles with [self != myself])with[
; j8 g; A, Z7 C; m(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : O7 ~) }3 d/ k" |/ n
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 }; d) R% j5 z. |8 }- \/ a
and remainder who 5 = 0
: b: b _0 Y( Q5 s8 [] 0 S# z0 Y8 S. g9 J# q# ~
ifelse any? close-mates
$ `4 Q9 S. U7 c[
& }( p# ]( W0 ~7 Hset closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ s1 o; d# G& I* t# ?; U# ~
face closest-one* u! a2 l9 N6 w/ ~% d9 ]
rt 180
& h0 i6 n+ _: r; L t4 O2 bfd random-float step-size
& ?( W6 z' J# K' R% E' Favoid-walls
* a% x8 f3 m) t& [/ Uset stopped? false]$ r$ e# \1 a; z% o% c, x
[set stopped? true] 7 u& p- D1 a- R) H, [) N" E
] |
|