|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" P5 U. n& q v3 z! b6 G Kto go ]5 r0 j4 O0 k3 P2 ], R/ [
if not any? turtles with [not stopped? ] [ stop ]
/ ~# B" R' o5 X3 f( [% B0 rask turtles with [remainder who 5 = 0] [9 c' Y9 F0 w0 r7 ?
set close-mates (turtles with [self != myself])with[
; s# k7 a3 g9 m8 X- I' P(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 6 v! b+ [& x: c. K; b V. P3 h$ S
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 ^ r7 B1 ~' t9 c3 [and remainder who 5 = 0 % N6 |' c; E3 Q( h- e, k0 Q: X
]
: T+ I, g- y+ `+ _( n7 nifelse any? close-mates
8 e2 Q ~$ G. q1 {7 h3 Q; ?! Q/ J[ 9 A9 H) C# c# r* \
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 }! o4 n" {6 C; w5 V$ T+ Tface closest-one* P! Z+ `6 s* b. w* U& }! n
rt 180. J1 ^1 w1 k' S* F2 \1 w `6 U8 |( Z
fd random-float step-size; w0 ?* k0 p* Y1 h7 g+ l6 c
avoid-walls [6 C0 Z$ }' g1 b2 d# k0 k
set stopped? false]; j. D9 R; a4 N4 }. x; `8 b& d
[set stopped? true]
/ k- H7 b5 l f+ t$ F2 _1 L$ N] |
|