|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false6 q/ f- T! h$ ~2 A
to go0 Y. q3 W% ~ O( x
if not any? turtles with [not stopped? ] [ stop ]
; J r1 x0 O7 } @; k) Wask turtles with [remainder who 5 = 0] [+ r3 j7 O* B* k/ o3 t: h
set close-mates (turtles with [self != myself])with[
( R6 r2 R8 d6 ~- H& C0 e(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( K P/ q, _" Y1 w+ wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 3 ] M1 Z/ T% P! n
and remainder who 5 = 0
1 B2 D/ `' { B* Q) f. g/ [5 a] ' i, G0 G+ ?( `$ V: Q
ifelse any? close-mates
+ `3 Z p. a$ y) o5 J( t' p; l ?: r[
: {# ]; t, M! Tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
+ s- |: r. \* Fface closest-one
, O" k. }! P7 r# Y% T4 Ert 180
! Y4 U+ z" y# O% X$ l& Hfd random-float step-size
2 U' _' l/ P! H* L) h7 T. d6 davoid-walls9 n- f5 i8 D/ R. Q& ?
set stopped? false]
+ A0 N" o' t4 A8 b, G7 j& M[set stopped? true]
6 I2 ?0 |+ Y2 z2 L8 Y] |
|