|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, r4 _5 U3 g# B3 [; I6 \/ N" }to go
0 F* F w" z+ o# s, c6 J( Y1 vif not any? turtles with [not stopped? ] [ stop ] * i; i4 N- J$ D" H3 V
ask turtles with [remainder who 5 = 0] [/ i$ j' H7 i2 f2 b. U' C7 A2 {( D
set close-mates (turtles with [self != myself])with[! r# j. U0 o6 G U- u: R
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) " p4 a `2 b) r. o+ g$ C
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 M9 n) _, K9 b+ \0 L! [and remainder who 5 = 0 $ H. D* _3 I- D; D
]
8 i& [2 g- `' ^+ V Rifelse any? close-mates , U) p1 i: L$ S9 }1 D; o1 i
[
3 C- m6 `4 h- |: V4 J: lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]- G' \8 Z( e# z, D6 F7 ~ v0 l
face closest-one, X G8 n5 s/ f+ l" Y
rt 180/ w2 G- Z& r6 a/ z0 V8 I
fd random-float step-size
: D) l( B y9 Y1 P2 i. Favoid-walls* [! j5 P' z" G' [/ A) P
set stopped? false]
4 J5 u, _2 x4 }) d) n[set stopped? true]
9 I( ~* I5 ^) [" }! Y] |
|