|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 e: X( R% s6 {to go5 U, q/ E+ }. V I% C8 G6 A" w
if not any? turtles with [not stopped? ] [ stop ] ( I6 p- l$ ~ k
ask turtles with [remainder who 5 = 0] [! D, e9 U* r2 e
set close-mates (turtles with [self != myself])with[
8 p+ y9 X7 d6 c6 x; g6 B5 j(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( j$ [9 I8 S3 {and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) u9 C$ b9 Q- q! E/ U* |
and remainder who 5 = 0
, f% r2 ^8 g8 U* Y5 o$ M2 g! F]
1 r( W2 f5 e! D x) t& Qifelse any? close-mates
" t2 n9 ~. D |# U( j) a0 ][
: B. i0 M3 x0 V* U: H6 m/ R2 Sset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 u' }& t; l+ Y0 d9 Hface closest-one7 l) i* \6 F3 B8 C) A
rt 180
0 X$ s3 i- J; o# Z: a, U! ?fd random-float step-size
: t& h5 }$ b2 s Z& @& \7 R( W" oavoid-walls
- K$ ?8 W% U2 R+ f9 yset stopped? false]
+ o7 s# j B' Q2 ~[set stopped? true]
) Y4 s3 \( |' M3 a] |
|