|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: z! v9 V3 [( u7 l& q& m( D
to go7 z* b( p5 Q% _4 N
if not any? turtles with [not stopped? ] [ stop ]
! Q& G& K9 p- V4 v1 r1 oask turtles with [remainder who 5 = 0] [. B7 H, {- D' K# t
set close-mates (turtles with [self != myself])with[6 {* h( f8 E6 V# I+ h/ T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& ^1 `$ k `! I. e zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
* K; ?: e7 X$ U. i* @" nand remainder who 5 = 0
" I/ j5 b. Z$ G! ?9 e% Y! g5 a]
7 J2 X k; k5 f( o Iifelse any? close-mates ; {* Y5 P* K; s9 h! {. A8 ?: \; j
[
) x1 |: p7 I* i; lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. D$ w2 E, e3 e2 P; _
face closest-one
4 W0 H" f) I7 j5 l/ O8 V% Prt 1805 U6 S. q3 U2 q( S
fd random-float step-size1 L, A$ a3 b$ T* q; V
avoid-walls
; k& Q3 l: |# Mset stopped? false]$ |/ S+ i0 m% x6 e! ?, a1 f3 s' f
[set stopped? true] 2 p* W: ?8 `/ k
] |
|