|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false# i; W' T2 n3 d! V% L# ^ j
to go5 ^* W8 A8 C# \" w
if not any? turtles with [not stopped? ] [ stop ]
R! X0 @& ?! B* O2 I& bask turtles with [remainder who 5 = 0] [ n0 I" I2 `# S9 u3 j3 s
set close-mates (turtles with [self != myself])with[8 q9 J; ?: E* _" o8 ~# Y& P
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- c; D0 P; ^, b( o& Kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! O* N) W: F% ^, Z9 d1 \( s# ^and remainder who 5 = 0
5 N+ u7 m5 J" K7 }' B1 P) k" `! K0 @' ?]
2 G+ j3 h! W( _; T0 U5 Gifelse any? close-mates
0 b: _8 C6 B) E& c* v& ?4 A$ x[ / N4 i: h; d& H6 j% p, a/ H
set closest-one min-one-of (close-mates with[self != myself] )[distance myself], S+ I9 v+ z9 w! m3 A
face closest-one
' L7 P) B/ f( \& zrt 1806 U) W* T8 A- Q
fd random-float step-size
" `% G$ e/ c3 c" xavoid-walls
9 x$ z( g* O9 g0 Y0 ^* B) @" hset stopped? false]) D5 f! D& |$ |$ Q# K1 ~1 T
[set stopped? true] ' `) \ I( R2 R2 O2 P# A2 o; k
] |
|