|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false' F" e+ g" Q4 V+ ?( k/ D; C2 f" G) U
to go+ b, T) J. `$ w& t* _
if not any? turtles with [not stopped? ] [ stop ]
; }7 F6 B, p( oask turtles with [remainder who 5 = 0] [5 i1 P: A. ^. s
set close-mates (turtles with [self != myself])with[$ O% J; c7 ^' y
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / ^* c8 _- L9 t
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) & B4 b* z9 G$ _. ~; O
and remainder who 5 = 0
_7 H! @+ P( \% C, B]
r2 Y+ o! Q. E" e, N0 z7 E2 C( hifelse any? close-mates
5 S! g7 K+ r9 e n u[
7 M) W( ?$ B: j* j0 Mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]( R3 x+ w0 B! {. u" R, P) v# t* h
face closest-one
5 k& {5 _ G9 m# F) V2 W; H+ qrt 180
5 ^0 ^1 t5 n' ^2 y kfd random-float step-size
( L" f! _$ m" }avoid-walls
3 ]: e$ S0 X0 y/ @ d2 Lset stopped? false]7 C7 h9 {$ Y) `1 F7 P+ \0 j2 c* U
[set stopped? true]
: `( [/ k. }1 N1 L% ] i3 y] |
|