|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 p$ `% e6 m2 |$ k; `* ]. nto go( j- u5 H& H& P( x) }
if not any? turtles with [not stopped? ] [ stop ]
* _3 C, u2 _( L. kask turtles with [remainder who 5 = 0] [
( U( l! w A% C3 L3 W/ [3 F$ M$ ?set close-mates (turtles with [self != myself])with[
9 R( L6 g& D f! ^(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ W/ g& v. x w U/ W* E' Yand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . ?' m7 b! z' b k0 f X0 x
and remainder who 5 = 0
8 t! B4 `6 y/ G' i]
& z( v/ S, }- Iifelse any? close-mates 6 s5 ~' i: d: ^0 U( N! c
[ * p3 D6 h8 {( k9 q- y" M
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
+ W+ c6 e4 F6 |/ d4 V* [) c, cface closest-one
, Z5 V; C9 s% [8 T3 q/ irt 180
8 S2 R5 j9 I B# Gfd random-float step-size
' E6 r" Q5 |# X& }3 [4 {avoid-walls. v, ]3 ^( a7 s) Z. j& J% X& p
set stopped? false]
8 O3 D0 e7 b5 x! N[set stopped? true]
& K: P5 s* k- I/ y2 g] |
|