|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
/ B% [; B( b8 Pto go
" v" z4 I2 ]$ ~% @( A* ]( [5 [if not any? turtles with [not stopped? ] [ stop ]
7 x& P+ M) r7 Q5 B7 G6 a" Bask turtles with [remainder who 5 = 0] [
& Q% O0 U0 z5 Q( I1 f3 gset close-mates (turtles with [self != myself])with[
5 {0 e0 w* F+ ], ~2 @/ Q# V(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) . B9 s8 z5 z x* Z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 5 O2 m, Q \0 Z% w- M7 _
and remainder who 5 = 0 , K' Y0 {0 b4 j/ _% G1 x; H8 B. g% t
]
4 V& X( Z z b8 w, B/ pifelse any? close-mates
8 b2 b( P! }' r7 h4 D3 u[
. l* z' ]) J+ }, X6 L: [set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) o* H6 \+ T% o; ^' O- x0 k6 pface closest-one
5 a2 R$ \- B Crt 180
" J( U! Y3 |) k O6 yfd random-float step-size' j7 H, u5 e) ], k( T
avoid-walls
+ W" w6 d) k+ bset stopped? false]
4 H- Q: b/ z$ j9 {- ?[set stopped? true]
8 d8 C3 W4 n% Q; U] |
|