|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false0 b: x- e! j( S" k: i) ] A
to go4 ~8 @! d9 y9 U+ P# h: b4 ?
if not any? turtles with [not stopped? ] [ stop ]
E3 }. s& P" l9 B M) N* V( a2 L9 gask turtles with [remainder who 5 = 0] [
' Y7 Z+ E; T/ v: t( ]) h$ g3 bset close-mates (turtles with [self != myself])with[5 y. Q+ T) t+ R0 |
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& m$ y" [/ j4 v" Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% J! b3 R& e+ {and remainder who 5 = 0
a. N4 }& p3 M2 a1 f] 7 Z, [, V# H9 Q% p/ M: t. ?) z
ifelse any? close-mates
: `$ N; |. Z5 ]0 T8 e[
& i0 g; |+ `; H- O/ y0 iset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
- E! | D+ B/ n* z( p5 C$ i8 ?; gface closest-one
1 h9 D c4 N# M# j* n% Nrt 180
0 I) @- w9 Y/ Z5 V# |; C3 z5 Gfd random-float step-size
; H7 Q: g: g# j3 |) Cavoid-walls
: ^! b$ Q2 F3 y7 Q8 T( tset stopped? false]9 c# h1 R% a3 I
[set stopped? true]
% _* Z, d* j6 R] |
|