|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* w* x3 ?% E Y% \, q2 j2 v
to go. I5 y+ ]6 K" S5 J+ f' ?
if not any? turtles with [not stopped? ] [ stop ]
' K; A, T$ C: i7 J& c4 L8 K3 k' ]ask turtles with [remainder who 5 = 0] [
9 A% X3 o- }" j5 H& Y9 R- [set close-mates (turtles with [self != myself])with[
3 n% r3 B/ E7 a% C7 M2 m( d2 N(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 E$ q' ^4 b/ y9 ]9 [0 e5 |( ], e7 @and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! @5 E+ g9 X) x7 G7 c5 V3 sand remainder who 5 = 0
( @: U5 D7 y0 U' f9 }]
/ x0 K; n% @1 k rifelse any? close-mates * S" N2 e. i+ ^, C
[ ) y- U9 r! k" \) i' C# ]
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]3 F W. D5 T7 ]% V; E
face closest-one
7 r" p" P. I* b6 v* d4 Xrt 180* L1 l, }; G- z" q# p4 U3 J
fd random-float step-size$ r( o7 X I% U
avoid-walls, P& B. ~) u& o! t1 U) |& }- b
set stopped? false]
3 ]5 A9 V0 }3 v8 I$ r/ B4 N! n[set stopped? true]
- o ?) _5 _2 R( p1 a2 [] |
|