|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 H$ r* X' O5 c0 ~to go( V* Z( F/ _1 i' J3 }$ o% V
if not any? turtles with [not stopped? ] [ stop ] $ W+ b# _$ H& t, X1 d9 U2 H* Q. G
ask turtles with [remainder who 5 = 0] [# Z- r6 s" v9 }* Q* X) |
set close-mates (turtles with [self != myself])with[
3 M7 ]: W2 X& k1 d$ E$ p(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 \# _# o2 L* i$ V
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
0 W; r! y( _9 d! wand remainder who 5 = 0 , _7 a5 b" ?8 m; }
]
' u( P/ v& E8 g5 N& }8 B3 v" lifelse any? close-mates * |. n. Z1 M* {5 [% {! K) j' }
[ 4 b+ \- v8 Q' r4 ~( d& {
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]2 p9 G! H! y+ e! l1 |6 [6 z
face closest-one
; H" _) Q$ q6 v! Yrt 180- Q2 q9 [) ^0 E N$ `+ Q$ H2 X0 e
fd random-float step-size
- s1 v$ l" v" s- I3 lavoid-walls; N1 D- y) ~* k0 C' L ^* ?2 w3 \
set stopped? false]# U7 L5 X; V$ S8 q* E( a
[set stopped? true]
, N" x. h- l$ e4 g] |
|