|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% `. ~, H# a, c- R% Q5 l
to go) h$ U) G* |1 O
if not any? turtles with [not stopped? ] [ stop ]
7 k) {+ w6 V+ k/ ?& zask turtles with [remainder who 5 = 0] [
3 z' @0 t% b6 i) R% l: Dset close-mates (turtles with [self != myself])with[
* R1 B* _; ^$ m- w1 x$ ^/ c0 ~) V(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 W" R+ v: R4 h/ \& q$ g; Kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! {5 Z" W2 d' y. m) @; j7 b/ a& dand remainder who 5 = 0
% S; |/ {2 w6 @) z] " g! g4 R; U8 [& D- w
ifelse any? close-mates
0 N. R' N- x5 z1 g8 F; C) R[
0 o) b2 W+ A) Z5 G' x& _4 P! b! O7 Yset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 j. S( m9 _# p6 v6 Y; \face closest-one
8 h0 k' M8 [) R, K4 ~3 N( nrt 180
* @ u2 I+ ~0 R+ Jfd random-float step-size
2 K" H( h E1 T9 C( Havoid-walls
6 N2 K6 W1 ?: h+ I7 {+ yset stopped? false] q0 \8 v2 a9 r0 {8 _1 u) g: V- B
[set stopped? true] 4 Z5 K/ P# \$ Z8 W# K$ s3 j
] |
|