|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) ?; r6 n6 F8 [' v' I. fto go
. [* S4 t s, M$ D5 F4 W' t/ b) cif not any? turtles with [not stopped? ] [ stop ] . u; ?# f, V( g& o7 t' C
ask turtles with [remainder who 5 = 0] [
& a0 ]. g" `# s, t) Pset close-mates (turtles with [self != myself])with[
% j! F d* v* u: T& [8 K% n- G; q(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 `( |; y7 @+ u3 \" z' S
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
3 g" Y0 d4 F8 ?and remainder who 5 = 0
" \* r) `# p3 }! r- O+ n]
' ?0 i: Y. }7 ]/ M3 Q/ _7 Pifelse any? close-mates
* u+ m4 ~$ b" K! W+ H/ J/ I[
; w9 x7 }. d) e) zset closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ r6 I2 L7 _& N7 O
face closest-one
; B9 m/ e# o5 N# A# Wrt 180
6 s3 @/ c& Z2 @2 K3 a1 M4 T" Dfd random-float step-size; R/ G) q* |$ N6 ]' o6 K+ C
avoid-walls8 I2 l( O4 I; f# k" z
set stopped? false]
$ L ~/ t8 b& F4 ]' J[set stopped? true] - K9 H& h9 }7 h" t: J5 W# S X
] |
|