|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false4 \: C7 M4 ~; `" W8 i1 y5 G8 J q
to go( |+ |' `1 i0 G m8 N5 K
if not any? turtles with [not stopped? ] [ stop ] 1 C C" S& K+ ?* E) z
ask turtles with [remainder who 5 = 0] [8 w9 B# x: w0 _& y( N' P
set close-mates (turtles with [self != myself])with[
/ @' |+ j" E* [5 t$ K+ _# b0 R(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
6 @) w, y' `/ Iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
# f9 w, K/ g3 s" {) V* k. Uand remainder who 5 = 0
+ }- D& F! i2 Z$ I% A% {6 E) q]
& v* o/ U! T2 K8 sifelse any? close-mates
! R- x9 O$ M# _0 h2 K$ V[ , F: `% r2 A- q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. z: _: w# x7 h* pface closest-one. b0 J; i" B8 v3 C& C1 W
rt 180. c2 P P& X }
fd random-float step-size* x. o% q$ _) E
avoid-walls+ S; p6 j; j. M/ b/ ]
set stopped? false]' l' l6 b1 n3 a0 `+ z
[set stopped? true] " B% t! ]' t; y$ [3 p( Z$ C
] |
|