|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 X6 `2 h2 H6 k w
to go' k& v+ h( r5 J
if not any? turtles with [not stopped? ] [ stop ] % F$ m, G( J/ I. b _5 s1 e$ U
ask turtles with [remainder who 5 = 0] [4 d a9 ]! n3 |3 n- |) d
set close-mates (turtles with [self != myself])with[9 a" h7 O6 U; R1 C5 y2 e5 D3 L
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 2 {$ h" S* k5 X% l
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 7 d& h$ \/ S$ f6 s2 \8 {2 B6 D2 s
and remainder who 5 = 0
& l: K. _( Q' G: x; F( J3 ]] 3 p D3 p$ Q! O0 K$ A. C$ g
ifelse any? close-mates
( p0 A9 I- \5 w: d. k7 Z[
/ ]& i, `3 T: @& c2 G5 eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 i7 b7 U o/ w0 [face closest-one
' j/ j+ a3 a8 {4 Prt 180* U1 j: h2 h( n/ E9 l* ^+ z
fd random-float step-size
Q8 [% {, b: R& x) ?avoid-walls
' D0 B5 p) J, @* d2 E$ |set stopped? false]7 n0 j( _, }* D/ S
[set stopped? true]
6 @% T. v+ f8 u1 J" q] |
|