|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* t4 |3 _. [/ l
to go
! w* l* p9 n+ |/ Q/ aif not any? turtles with [not stopped? ] [ stop ] # ?+ n: @ ^* }" g9 k
ask turtles with [remainder who 5 = 0] [
8 W S7 V! M& k f1 d5 N) Fset close-mates (turtles with [self != myself])with[
: x4 c: g) z+ W" ]' {(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ' G! v* Q+ e4 P3 w
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! W$ c. U$ J3 I+ W( Cand remainder who 5 = 0
" d$ g8 I& @! f& i% m] , d& D- E' K( k+ b! W. O! e/ y) E
ifelse any? close-mates
3 u l# J+ x h& C( p- [[ 8 ?+ X& ^$ Y6 ?( L+ f3 V9 G
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& d/ W/ S9 @. }/ jface closest-one
* P1 w1 s% d9 k$ e: K1 V7 P) E5 u1 _" [rt 180
4 G* ?( y0 C- Y6 B, [" g1 Efd random-float step-size% D1 M3 O. |# O( @4 g& z
avoid-walls
# c. N9 I b( w+ Z* o5 f& ]set stopped? false], f# s1 N3 H$ J% z
[set stopped? true] 1 f, d, ?2 o5 {2 d' l" R# s; \+ |/ d
] |
|