|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false, ~, d$ h) }5 @0 D
to go8 Z0 l; @9 t2 ]' A% Q
if not any? turtles with [not stopped? ] [ stop ]
5 l# @, Y- _1 E' m' z5 J* q' Oask turtles with [remainder who 5 = 0] [
5 ^) P' b" V) ~set close-mates (turtles with [self != myself])with[; `7 V* t1 t0 r$ e ~, z9 _ f$ o
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% O, L1 P0 }5 i5 ]and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 n) `. v" S+ B6 dand remainder who 5 = 0
: H; C/ r0 V* z* u2 M6 E! {]
3 p! d) Z0 D: z% Oifelse any? close-mates # `1 B3 L( X* ~# ?0 I
[
1 u0 r: k/ o3 J7 j- {* Uset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* e, e" r( @2 L, vface closest-one c) D v# z/ V3 F& K
rt 180
6 ]0 Z" y* Q4 F5 y, ]fd random-float step-size- A S8 i: [* L
avoid-walls
- u& F2 {; j: D) {3 R6 {set stopped? false]
- f- M5 f( _/ w. ?1 ?" \; Y% ^! Z[set stopped? true] & p2 |0 K$ _' L
] |
|