|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* _! ?* y; F' S5 q4 t
to go( c/ G9 a& E7 ~0 k' M3 [/ n
if not any? turtles with [not stopped? ] [ stop ] 7 G$ o0 w4 I9 _+ M1 F) S" U
ask turtles with [remainder who 5 = 0] [0 g3 ~+ H4 Y% L/ M6 n& W1 i( P
set close-mates (turtles with [self != myself])with[2 j+ V0 ^+ C( j2 E- \
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- b! X; ]2 K! kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ; U, I0 C6 Y4 I- @2 V# T9 M
and remainder who 5 = 0
% i6 h2 M# l/ v; F]
6 y5 `1 ] O5 T3 L- s: Z) lifelse any? close-mates
Q2 T+ P+ D9 [! V+ M1 A- \; C[
& {$ s- k0 [/ oset closest-one min-one-of (close-mates with[self != myself] )[distance myself]1 u1 C; A! y* M" }
face closest-one! B9 d* u$ z; A* l0 d
rt 180* w! c" w3 Q) R
fd random-float step-size* j, \$ O' M; G- i/ V; Z6 D$ Z: O
avoid-walls
. H& w9 h0 X: ]5 U0 ]7 Y$ L1 Fset stopped? false]
m. u+ k& X; y/ v, ^[set stopped? true]
6 k) w' P, M! W( O" L$ n] |
|