|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ p* m$ f8 o* t$ ?8 f- T {, |$ b E% k
to go& h2 `. j& o8 t. z, W
if not any? turtles with [not stopped? ] [ stop ]
$ G! F- F$ \! o) r% Yask turtles with [remainder who 5 = 0] [3 h; U5 b8 \6 b
set close-mates (turtles with [self != myself])with[4 r3 @' g( l' J- \
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 @9 z' \8 a' I* t1 z! Eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% M6 S4 s6 k& O Z: e! c( Land remainder who 5 = 0
% J6 m% C& z% k7 Z1 Z9 y( I% g0 l] & T: h) i. f# C& l6 r
ifelse any? close-mates
# x* Y$ v- N5 }5 I3 e[
( r$ p7 A+ A2 F0 V; qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]: Q& V9 Q! z$ G2 w: H2 H1 n
face closest-one ]$ z; f- m2 H5 g1 O
rt 180- q8 u" Z) \9 m8 X) K/ W4 T$ k6 B. R
fd random-float step-size
6 W @- C. A5 B4 g% {avoid-walls& Z' y' v Q2 M! a9 p2 a
set stopped? false]) p/ B* Q, ], i- s" S" h! m
[set stopped? true] % [5 b/ g2 w$ d3 i
] |
|