|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false4 C/ S( U, |) h# k3 ~" J
to go8 j) ?+ \$ \0 i! n+ |+ @) t
if not any? turtles with [not stopped? ] [ stop ]
7 {, J$ P; p6 p9 Nask turtles with [remainder who 5 = 0] [8 ] _& T( h5 |6 h
set close-mates (turtles with [self != myself])with[
0 F/ q" {5 R) w3 | t" n% `8 u# W! i(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) # q# g% y( {% e" b
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
4 k5 G. U/ O( F( V4 rand remainder who 5 = 0
7 i3 q: O- q' B% r* ~] 3 o9 z5 Y7 A2 r! e1 N
ifelse any? close-mates ; _! f/ b" v! q5 D' z
[ 9 }5 B% o1 `, w
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]6 {7 d g4 t5 i0 x
face closest-one
: h0 T' d' F* ?0 T' g3 ?rt 180' O& T1 z% Q7 m( Q$ W* q. ]
fd random-float step-size
?5 k5 Q" Q9 F/ F* Wavoid-walls
3 s, k7 B2 `) Iset stopped? false]6 \" [2 w ^) D8 d: H& G* x) S) N& d
[set stopped? true]
+ ]. [, y! E, G% Q. L1 X: C] |
|