|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" [* n. I- }5 q0 _9 O1 lto go1 P) Z, ?* x9 e! f1 ^& F
if not any? turtles with [not stopped? ] [ stop ]
: }1 t& t3 q7 ~6 }& {ask turtles with [remainder who 5 = 0] [
+ L4 _ G" ]7 @$ m- aset close-mates (turtles with [self != myself])with[( U: M" ^9 w, e/ q
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ' S* N/ G! i Q9 J
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 w. z/ `5 j% U1 Land remainder who 5 = 0 + @0 @: @! g" N, o! z
]
% y9 s( n4 u: Rifelse any? close-mates
5 [( W C8 a ^& \2 q; d5 v[ $ r# f0 F" Y+ Q2 n
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]1 U8 b: R K! W3 Q7 t
face closest-one
% ]6 p4 E! }% O8 c) ^" [4 art 180
; K+ P, X) M0 ?) ffd random-float step-size' j" S7 ^4 I: A; f
avoid-walls1 [* e: K5 _! ~5 {$ v
set stopped? false]
8 b6 f$ h. o D[set stopped? true] % j: P7 W! z- c1 q* H
] |
|