|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! a8 N6 C# @( h A9 `. `% ~+ Cto go+ t8 i! Z. e" f9 C; f! i
if not any? turtles with [not stopped? ] [ stop ] 2 T& s j# P$ y3 d$ f. Y4 V
ask turtles with [remainder who 5 = 0] [
& }0 C1 e8 D8 d' Oset close-mates (turtles with [self != myself])with[
" D& x% U2 G) V' d(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ' @4 e8 y, H, U7 U, w6 ^- S: v
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. a1 N+ W# [! @; T) @1 Band remainder who 5 = 0 ! c X b D8 J2 W
]
& J! Y7 N {) n/ M) M3 K7 \% C. Nifelse any? close-mates ; S5 Q# ~8 c# t0 {9 j. l! {) K: W C
[
5 R* M4 _1 T5 m* _set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, a0 D9 r! ~% P! u0 @face closest-one7 H: k6 \6 H6 Y, b8 {
rt 180
. B( X% s8 i+ f5 hfd random-float step-size
0 s2 E7 b* r9 J6 p) o r+ _avoid-walls; r3 z' k: `& ~, {& P) D
set stopped? false]
3 R/ k; J9 w) y2 t[set stopped? true] 0 P8 c- F" t* _+ Z u. O& L: N' v
] |
|