|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false6 D1 Z/ W5 F4 f4 `4 [
to go, o& S7 A0 }8 f
if not any? turtles with [not stopped? ] [ stop ] : w% h( Q( O6 Q z4 m& }
ask turtles with [remainder who 5 = 0] [
# m( n& L0 p" F" G: }set close-mates (turtles with [self != myself])with[
g; ~; s" A' f4 \, V4 ]) K( ^& w(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 ~, H ~, r* X& x& D
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) # q, Y9 I- { D# j9 B2 Y5 h3 C3 h( Q4 ]
and remainder who 5 = 0
8 }; Y3 P3 {& V8 m3 w2 I] ' V3 w- a% J8 ?$ J( l8 Q- F
ifelse any? close-mates
k2 B' j1 m: U6 D- |, x$ o[
# e/ Y; t. z' H0 H+ dset closest-one min-one-of (close-mates with[self != myself] )[distance myself]# h1 ^1 D+ Q H
face closest-one* x7 C7 a/ v( J7 _0 V$ Q$ Y! ?
rt 180! q9 N- M) ~* Q2 F* p; W
fd random-float step-size6 o Q" t- C3 M. m8 g8 A0 Z
avoid-walls
7 Q# Z w: C+ G6 p0 [$ W Q. A" h4 Wset stopped? false]( j0 p: x% ?$ w
[set stopped? true]
' H2 c1 A, u/ I: b9 d& F* R] |
|