|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) f9 y6 N6 s% G9 oto go$ x% e2 B3 a% P" `7 s" E
if not any? turtles with [not stopped? ] [ stop ] + A) s5 L4 ?' `% V& S7 s
ask turtles with [remainder who 5 = 0] [7 W' y# u7 o& W E
set close-mates (turtles with [self != myself])with[( `; Q8 g, \' Q* ~( T0 Y/ }
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) L* z, b! h$ Q
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " H* X* x C3 E; P" v& N: X/ o
and remainder who 5 = 0
2 M. N8 R0 L; ~3 H]
$ B7 s$ k5 V4 c, z: I6 J. gifelse any? close-mates
- ]. L! _* D$ R- s[ , ^! u( a5 Q2 e9 d
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- {4 |( C& E: o/ {0 V3 l1 @# I3 \7 G
face closest-one3 x- c0 t; _! y8 K: m, Z
rt 180+ }1 q& n0 r, A% c" H6 [+ f
fd random-float step-size& v, r" y3 l( r. B/ P
avoid-walls
3 h& U8 J2 x, M- c" N$ X5 {set stopped? false]
3 S; \+ d) {1 P9 C[set stopped? true]
( M5 g; f' T$ A- o: \] |
|