|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false7 o2 t- \: o/ f. V' X
to go- f" @: m, O' ^+ W; z4 q8 O2 v
if not any? turtles with [not stopped? ] [ stop ]
" t9 | g+ ~4 [# H; [# _ Bask turtles with [remainder who 5 = 0] [
) s. L6 c( A* J. l6 Vset close-mates (turtles with [self != myself])with[* z' c9 ~& d5 M0 u% c' _
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 I4 y2 M# U. }and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 q {% Y& H" z% Z' ?) j5 t% kand remainder who 5 = 0 : _+ [, j( E$ P5 N9 ~! R
] / P! T+ }& i8 m6 z8 g& j
ifelse any? close-mates \; x; [+ } Q+ R9 b
[
/ b0 D, p3 h6 k' b9 G/ F+ x$ lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
+ y3 F* g, F% r8 Z( X+ sface closest-one
6 h- S; Y1 T- crt 180
1 A! J+ W, t6 `1 N* K% kfd random-float step-size
2 n3 d0 @0 t3 m+ |1 V0 kavoid-walls `2 }# c' w2 I; d) A Q
set stopped? false]: c8 s8 i2 N( k P' l. A0 P
[set stopped? true]
% U; J# ]( U: p7 ^] |
|