|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false2 J- s) u$ Q% ]# Q
to go
# A& b& y8 Q3 e0 k3 m$ O% D+ \if not any? turtles with [not stopped? ] [ stop ] % j) f2 ]8 F0 Q6 s" X0 L/ G
ask turtles with [remainder who 5 = 0] [
4 m- | ^* Y6 n5 Y; \5 i7 ?set close-mates (turtles with [self != myself])with[ G1 Y/ _8 z% j8 u
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) & b0 b2 G) e8 `& B8 y) E
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 }6 V' z$ n% r: l& n) n+ u) jand remainder who 5 = 0
: Y0 c3 v% n, @! [9 Q3 L, J5 h. x] 1 [& G2 x# U2 @2 f* n, a
ifelse any? close-mates
. K! n# u& g9 \& I2 ^" |9 n' O[
2 P y5 R! Y# Nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]' }9 ]; U" x% ]+ e; B
face closest-one2 J/ @7 t8 K0 ]" q0 }5 X9 [! H
rt 180 r$ J& P, E/ k) Y" F' c8 f6 Y
fd random-float step-size) [# l2 b7 x4 m, q7 a
avoid-walls
' L, N5 [* _$ sset stopped? false]' e! i" A+ ]5 X: n/ B# x" E2 x
[set stopped? true]
2 t! _, x- o# \] |
|