|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false! R R1 s- j6 [* k9 g( @
to go S( {: K5 d) d3 L
if not any? turtles with [not stopped? ] [ stop ]
& z: L8 C3 \8 M& D! h8 a( |& Uask turtles with [remainder who 5 = 0] [ z/ k1 U/ E# K2 W" f9 h0 ^
set close-mates (turtles with [self != myself])with[, s6 \* f$ u! Y2 X+ i9 b9 t
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( X0 e( t) d" i5 C5 o
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: W2 {% r6 C$ Hand remainder who 5 = 0
; u' b0 i4 y. J! S3 }! u. k]
m2 T& ^6 i' w- Pifelse any? close-mates 9 f- F: j# N3 r% n: s% @
[ ( l% M( q v6 f' h
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ z4 _1 l/ r' C0 r! ~
face closest-one
! c8 T, E7 b( G1 Q, F n) s* Nrt 1800 S! C8 a9 K) i8 a/ I
fd random-float step-size
/ Q/ h; V$ x8 R! T5 Xavoid-walls( ]1 H' K) p8 x
set stopped? false]
# ^. E$ j4 n0 z! M: l5 M4 S[set stopped? true]
6 q, @- I {0 K y] |
|