|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
9 J0 J& g0 c* I: j" ]to go/ w" T! f2 j$ _% K, i
if not any? turtles with [not stopped? ] [ stop ] " |8 M+ `0 @9 i% z, X
ask turtles with [remainder who 5 = 0] [
- F9 F/ z4 x4 l, R. z& i" |set close-mates (turtles with [self != myself])with[4 F. y5 r- F3 }, Z9 e
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 L h5 q6 t" V7 Dand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. [& r( j' z2 u8 R& `# V* X8 d3 Gand remainder who 5 = 0 " S7 D$ z8 j" P" j3 f
]
# ?$ r) G" B/ Y( M# E# O3 tifelse any? close-mates ( P/ N, F W* j
[
2 P: R1 _( w9 D8 B% e1 nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]6 ~) X* a* _# R, g
face closest-one
$ ^1 _" i8 y& E7 S" K5 n' K5 c) S2 Xrt 180
6 W7 q# s, ^& T- l+ x. F( vfd random-float step-size" C7 B/ G$ J. n$ [
avoid-walls
3 }+ J7 R( r2 U; }set stopped? false]' v- Z. E' U$ `7 V# A. `& P) n5 W
[set stopped? true] % D9 \5 d- U8 _" T2 O& C% p
] |
|