|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" I) M( L. H0 x$ @! \0 u# }
to go7 Z$ a) {, `* X1 j
if not any? turtles with [not stopped? ] [ stop ] " ]4 @8 o' P9 T1 P; [
ask turtles with [remainder who 5 = 0] [
0 U4 [/ q2 ~ a. k' Uset close-mates (turtles with [self != myself])with[7 _2 ~$ w" g1 B
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
5 ~, _' r3 c% N4 F& C( a# [and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / s9 }( M+ u1 o$ f8 Z3 O/ H, m
and remainder who 5 = 0 7 h' c* d9 n: M9 J
]
8 l* |" S4 h+ W9 A# Eifelse any? close-mates : s( R" h" D0 q; w" M
[
1 ~, k. U+ r1 J9 ]set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 x7 s& M4 T9 u# t8 p, W1 K. nface closest-one
+ W) Z& Q# o: l' h0 Urt 180
) P! h7 p( P/ d$ ~5 i4 ]fd random-float step-size
) m* {- M% n4 `, _) Oavoid-walls
4 o$ ^1 D: y. ~7 _4 I' [+ uset stopped? false]
4 z4 C" i J3 t, N `[set stopped? true] & W* {- v* P3 o4 W5 z
] |
|