|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! I( j4 t- ?, H" j3 [9 r- i& W9 cto go
0 V: P' O+ S0 |# z% l/ Mif not any? turtles with [not stopped? ] [ stop ]
, I+ Q4 L; X0 m. \- H0 Hask turtles with [remainder who 5 = 0] [3 R( c- s$ e, }' k, u, |
set close-mates (turtles with [self != myself])with[
1 R/ q: G0 o5 c! y$ G: R( Z$ J(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) " e! J4 b! _5 \1 X1 y1 M, K
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% L( k# d1 `# ~4 o( K1 Dand remainder who 5 = 0 ! O) s$ B: a, n
]
R: F$ Q* U1 Q1 }ifelse any? close-mates
E: P, {7 }0 w* b/ h5 b[
1 P+ }" h7 M0 K; Xset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 {% z9 A0 B0 U2 V. I0 ]face closest-one& w5 K- A1 L/ e x1 J
rt 180
- H5 W* G% Z6 w* b' Vfd random-float step-size* N6 D. V& [7 L% U$ Z; x
avoid-walls3 \# n* c* J# D7 N" Q1 a7 [8 q
set stopped? false]& C2 P2 F9 L/ b/ Z
[set stopped? true]
. m* v+ @ P5 _+ q6 n] |
|