|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false, u3 d: ~/ l5 q: a0 }
to go
6 f% _9 I- o! ^2 O% C- _if not any? turtles with [not stopped? ] [ stop ]
& k: r. g l4 [1 R% n( N, qask turtles with [remainder who 5 = 0] [& m+ q8 B, P8 m
set close-mates (turtles with [self != myself])with[) _ }. u5 m5 ]4 |
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) % E; i, B" Q' R% c* k' @
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
$ x2 d$ ]9 t( k0 E7 sand remainder who 5 = 0 0 d+ G2 V: Z( D7 x
]
6 s) Z0 K! U9 }$ z6 z$ Y* I4 R6 U- fifelse any? close-mates
6 x/ m% @! C1 C. o* T4 k[ $ f& c' }$ e! b
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: e* f! `2 Q9 E; z, _face closest-one
$ i/ x9 O/ ~# ]7 f$ w4 xrt 180
' H4 E/ ^ U: ifd random-float step-size
( g* J S d) Oavoid-walls
1 l* ^3 B7 } e+ r: i* Gset stopped? false]
/ k M: l' j8 W[set stopped? true]
9 {8 N3 f0 b- d: S] |
|