|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) M" F& o0 {/ T' s, N1 y$ d8 _to go3 P0 I6 m6 l* G* F8 {& b
if not any? turtles with [not stopped? ] [ stop ]
8 {- l* Y, Z0 w1 ~+ U% W6 [ask turtles with [remainder who 5 = 0] [
3 F' C' u7 W# ]& ]% J+ ^" ]1 e0 J3 D; kset close-mates (turtles with [self != myself])with[# p5 G0 |& J6 d. F% y" T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
$ o0 ^+ ^+ R$ R# T# y4 |+ pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - }/ i# ^$ ^: w+ f# [
and remainder who 5 = 0 0 z) c9 D2 T# i$ B
] / }+ N" [( a) w& s# \
ifelse any? close-mates : X6 f7 l/ ] T9 Q6 L" x
[
: y& i: f' v! jset closest-one min-one-of (close-mates with[self != myself] )[distance myself], s$ q6 i2 j+ G* T& [! X
face closest-one3 W* k0 D* x4 y* [' V# {. ]" g
rt 180 g8 F$ E& d3 j/ t; J) z7 O/ o+ i3 ~/ o5 A
fd random-float step-size
i4 ~# c6 s/ }5 [avoid-walls* K( C3 V; E& U6 N8 e
set stopped? false]
: r8 ]8 l/ V; N n- c$ p7 G[set stopped? true] 8 B% k3 Y" ? d
] |
|