|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. Q! q" ?: j N/ k+ w. R
to go( L6 e, a( Z: h3 i0 H: J
if not any? turtles with [not stopped? ] [ stop ]
5 K8 X5 K, ?, O- o, hask turtles with [remainder who 5 = 0] [
$ S0 Z |- v( {- rset close-mates (turtles with [self != myself])with[; c3 T! O& V0 V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& s9 K" S0 {; ] Q% a7 L" Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
# I( R0 `2 [5 Q; G7 G; B' Qand remainder who 5 = 0
, |( m2 M0 } E- e]
1 A8 L; X# Q @: C/ z4 _" tifelse any? close-mates
( ?2 X7 b& {* V3 K[
( \- G* V9 c6 M# i b3 G* ]4 eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]# H5 p7 C( `1 Z1 r4 E
face closest-one
6 k$ o) O3 V) S& o* U+ vrt 180
! A l9 Z) [" F" t$ Ifd random-float step-size% U1 u8 {! q' [3 A0 O; J8 c5 ^: t. p
avoid-walls& Q* L) g: p$ L; M" v8 ]! ?9 E
set stopped? false]
' k* y' i; `* j' h) S[set stopped? true] , P/ ?+ y& G/ Z9 n4 E
] |
|