|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
* |- O- X/ P% V# }9 x+ oto go
1 `$ n; b' G! ]5 c( l1 B. Bif not any? turtles with [not stopped? ] [ stop ]
9 p! Y* l4 z" p, dask turtles with [remainder who 5 = 0] [
, y9 `* V) Q6 ~( E- T; ~4 Xset close-mates (turtles with [self != myself])with[
. R! l5 U$ b+ p/ `( F7 F(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
+ |; w) W8 Z; M% u( band (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 W8 n4 p. G9 f( b
and remainder who 5 = 0
) x' _( k& d% A! D9 w& c2 ?]
% X6 f0 r( M& F' fifelse any? close-mates 4 l K" k7 C! o6 D: ^3 E) |
[ 0 B; F# H/ p0 U; g9 f: O! [
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]% {8 Z4 g c. m8 Q
face closest-one
$ X8 h! [6 S. G, d: { ]1 [rt 1804 V" w1 S$ V8 Q7 m( p
fd random-float step-size; y* [: W' ^) G; I0 Q% l# b
avoid-walls/ i1 n8 P! v' D5 ^* w4 C! _6 A
set stopped? false]% J- J4 K, t L2 S2 q! @0 b
[set stopped? true]
6 h- M# V6 Y0 \9 G( [4 x( p] |
|