|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. I Q9 G' V: ~4 S: Y: L
to go7 T& |0 ^! @. s
if not any? turtles with [not stopped? ] [ stop ]
: |0 P* v4 u* b, `' ~: ~. }ask turtles with [remainder who 5 = 0] [. z$ m. \' v1 _0 Y ~
set close-mates (turtles with [self != myself])with[6 u4 T$ }. Z( k1 l$ w, p: N
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( A5 A# o6 P2 Z/ O2 @; ^0 ~
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. T1 U4 w. o4 H+ gand remainder who 5 = 0 8 H' u( B) Y! [( ]
]
" R2 M; j1 J# g I7 j7 Zifelse any? close-mates
. n. c1 }4 u. L[
- V% A2 y; i- Q! ^9 oset closest-one min-one-of (close-mates with[self != myself] )[distance myself]* [& P; i: s8 Y% P/ x9 ?
face closest-one
: |' \3 Z, q0 D X, vrt 180
- g0 x/ W1 j# F" ~; k7 Q$ D4 Mfd random-float step-size/ L! ]2 l$ W- k9 I& Y! M% ?, T+ F
avoid-walls
' y( R+ \/ q9 d; q# E+ T: @8 n k& vset stopped? false]& Y2 Q0 j5 `+ h' o
[set stopped? true] ! T- ~! |7 p2 x0 j! y
] |
|