|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false- _* u5 a' x% b
to go: p- s$ b' Q. S! R
if not any? turtles with [not stopped? ] [ stop ]
( F. E5 b; {2 c+ `4 C( U, Cask turtles with [remainder who 5 = 0] [0 l; M2 f( n. g+ k
set close-mates (turtles with [self != myself])with[
/ `+ L0 i, e. z, o$ @' P(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 W4 f1 z9 f; V; T/ n _and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
/ @8 q" z" ^9 T+ oand remainder who 5 = 0 ) b( w3 B% B, o" W) U- b a
] 6 f- d" ~7 i& \5 a; B
ifelse any? close-mates
) s. V' s! Q$ H2 @, e0 P[
6 G& ]# U* U: r w8 n0 z5 t1 mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# w% B/ C- _5 _+ a, G3 U8 k& u: Rface closest-one/ p/ g: u6 Z, z& L5 u7 G
rt 180
) U6 @: P% K1 F7 D2 l+ d* t( |+ C2 {fd random-float step-size) ?8 i& j% d7 }0 i* P
avoid-walls
7 S; X2 `& B8 |2 m+ j% ~) }set stopped? false]
2 ?0 t. P: m' B/ g4 T! _6 |, P[set stopped? true]
( S% q" q9 r; }9 g] |
|