|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 T2 k( ^+ v' V
to go
" z( F5 }4 Z7 h) Yif not any? turtles with [not stopped? ] [ stop ]
4 ] B, w4 ~1 I' u% O* vask turtles with [remainder who 5 = 0] [/ |- e6 v8 f% u6 p( S& s. n
set close-mates (turtles with [self != myself])with[
1 h2 q6 j* j" m7 x6 A( [(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
" U5 h& v4 G; x# kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
3 w+ J9 \7 J+ A0 [4 L& Cand remainder who 5 = 0
+ `7 o0 Z. z, p' N# k9 a] 2 \5 |* P* l) b. v3 s9 H; f
ifelse any? close-mates 4 n0 R0 P/ s- A4 }
[
1 r0 |( N9 Q% h( V. d; tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]3 s& K* ? N& Z+ \* v* o: b
face closest-one
) F9 J9 M/ B+ H" d$ Nrt 180 m* R$ x2 U- e& A" ~3 i
fd random-float step-size
+ x& H& |6 U; G( s2 {6 davoid-walls
* t5 I: G1 m7 a7 G2 U5 xset stopped? false]
6 ~% I( l! s$ C4 h, s[set stopped? true] 9 }8 Z/ S6 Z; T% C
] |
|