|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 u" l0 j/ r1 I( d) Cto go8 e1 V6 L5 U( k6 `1 I9 o) s$ N" R2 j
if not any? turtles with [not stopped? ] [ stop ] ' s4 |2 l- s+ a
ask turtles with [remainder who 5 = 0] [% U7 E8 h, |: W- O
set close-mates (turtles with [self != myself])with[$ X3 u5 Z! [$ I. D! E
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 f; G) h# p6 u! Z. yand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. y: {5 K9 H( M! `" x. Y6 B: xand remainder who 5 = 0 , J# s6 ^# s( {3 d) q
]
& Q8 d6 f" Z8 K" [ifelse any? close-mates
1 u. ^+ d, o! d) ^[
& h2 U0 ~0 V" q* _0 W, Pset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& N+ O' Q K5 D1 Nface closest-one4 F9 \6 b8 v/ n* c& Q/ g0 ]
rt 180: s$ }) X! z: {- B
fd random-float step-size
9 P8 w" y6 {! B4 navoid-walls( H) L0 [' c8 A) A0 _
set stopped? false]
% p* W; l. X" w% V( k. G: }. \/ }[set stopped? true] 1 x/ {: S# w0 _ G7 G, r6 Y* Z7 @" B
] |
|