|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false; {+ q5 L& G+ o. s# d
to go8 z& Z: m K* F
if not any? turtles with [not stopped? ] [ stop ] * A! r3 y/ x' h9 y ^/ S" z, e
ask turtles with [remainder who 5 = 0] [
4 D; w' O4 ~. E/ Y& x; E( x. q! Iset close-mates (turtles with [self != myself])with[4 o6 d# G3 f0 H6 a
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 Y/ p% k+ w0 \9 |and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " U( m& d, b/ K
and remainder who 5 = 0
# ?) V* U$ v& Z$ a! U& s0 s5 z] + J7 [4 n$ N& l6 A1 m
ifelse any? close-mates ' L3 Y& |1 \. a* |8 h, U
[ + C! c& [# f1 C6 y
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
; ?3 x, { e; m- zface closest-one
1 }' ^/ d2 F% n0 B) l9 a. Drt 180' s$ X% U9 ^/ s! V9 Z
fd random-float step-size
8 Q6 h# s- b4 ^* javoid-walls
; \) Z7 Y8 m/ `$ nset stopped? false]
0 Q* ]( j6 F9 F) F( Y[set stopped? true]
5 Z( q3 B, F! z4 D6 {) J2 Q8 X] |
|