|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* A9 X- e( l7 Q& u' s2 R% Z
to go
0 m D2 ?( ^$ }, B$ D: zif not any? turtles with [not stopped? ] [ stop ] / R# e) O$ ~5 b
ask turtles with [remainder who 5 = 0] [
" \/ S! K. _1 O" \6 t" W6 Z) sset close-mates (turtles with [self != myself])with[. T* G/ E- o; x! d+ _( T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 W6 O& U2 _$ h7 j% c; U
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % a3 E5 |2 p+ T
and remainder who 5 = 0 " a, I7 n5 e4 y5 a" N% M- t& i8 @
] 8 v# D# U& V3 U& U, u$ W- t9 {0 D
ifelse any? close-mates " B( o9 J N5 @/ B+ I
[ & T& @0 R; a( X
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: a" e% k' E% ~! M* O7 h3 E* yface closest-one3 s }5 Y( I; }" N2 q7 G6 c
rt 180
+ i/ ~! |6 Y5 r4 Pfd random-float step-size
) o7 S v2 L2 U$ D. U2 ~0 oavoid-walls& S/ E: F! l! J/ [& Z" `4 c. G1 i
set stopped? false]' Z5 W+ T+ w8 B( G. ]/ C
[set stopped? true] 7 y6 I8 t+ t! U2 Q ]" Q' [1 V
] |
|