|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
9 L8 H* t1 S+ y0 U8 x& W6 W @to go
1 p$ |7 r8 b3 `2 ?/ ]1 F) \1 c( \if not any? turtles with [not stopped? ] [ stop ] 3 P1 t! |7 @2 M% ?4 V0 v0 i
ask turtles with [remainder who 5 = 0] [ f0 @2 C+ J$ \8 Y
set close-mates (turtles with [self != myself])with[
: m/ l8 W g: d/ t2 d(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
$ A7 q& }6 \& I' p. |and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
4 R/ _! d1 U5 z' Wand remainder who 5 = 0
) T' {+ T3 C- A" @: ]; \]
8 X, z9 Y+ A- z8 ~ifelse any? close-mates / S) `; _, r: M) l" w1 S, B# I
[ + u* f7 \( A1 J+ R0 [" m" G
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- G2 g. L( Y$ E9 S1 r* Y2 }1 F
face closest-one: p: o4 R: [. E3 G5 z
rt 180
4 d- Y/ O* H' u. Q5 Ufd random-float step-size- `0 r: S# L& `5 R- _# D
avoid-walls: _5 A1 q$ w9 m' x
set stopped? false]
- ]1 p8 [) b0 M[set stopped? true] B+ \& [7 _' B; k: S1 a
] |
|