|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false( k1 H- t3 a' R9 @, e9 ~6 Y
to go
. J) }# O/ G$ O& lif not any? turtles with [not stopped? ] [ stop ] a; E5 g9 p+ G) A0 M
ask turtles with [remainder who 5 = 0] [
/ L* `1 b* F4 e+ z) Q& Z1 sset close-mates (turtles with [self != myself])with[
+ g: |0 S: E7 y* T0 }(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
: L/ I2 F8 Y+ Eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 8 _" X0 C0 U/ M) k9 I2 i- v) W0 e
and remainder who 5 = 0 1 ]- I4 ]: H( X) T
] 3 N N- d( T n
ifelse any? close-mates ; }9 {# I2 S# a" _! Y
[
+ T6 Q( C# a( y! l6 O3 K2 Fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. E8 g# L$ [8 w6 X3 U; _9 `; v. e- z
face closest-one, H; ]: e2 a; }8 e
rt 180
6 `/ p8 a9 c- F, ~: u, Jfd random-float step-size
" { X7 u% n8 [( u. w; @, }" [! ~avoid-walls
5 P% S/ e& e2 Z q) lset stopped? false] |3 m2 j" N' m8 n: m4 ?( h7 w3 a9 p
[set stopped? true]
( W5 p& [, |0 S: s& N# }. [] |
|