|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false0 Y0 |2 x7 C$ g" w/ @
to go
( [! u# ^) }- P4 t% }. h* {if not any? turtles with [not stopped? ] [ stop ] ?, a" o K! Y F' O$ ?
ask turtles with [remainder who 5 = 0] [: [. X1 `9 n" R! I+ N
set close-mates (turtles with [self != myself])with[
( @& ^1 j4 k, m6 t0 l8 D(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- D M9 v! i5 j+ f1 U8 e5 C! J" dand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 6 B' @4 R/ p- w
and remainder who 5 = 0 2 s9 I% C8 r f/ ?' T/ P. k' l
] % C- H7 |1 o8 k+ _
ifelse any? close-mates ' T+ u( ?7 H$ Z0 W' I* G
[ ( w" d' E! a' l: o8 P! f8 X4 `
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- N& r q% T# z
face closest-one
X# e' Q1 s3 Vrt 1802 y3 | Z, E) b# o. k; e, m
fd random-float step-size- N" }0 E1 ^8 C
avoid-walls
) _4 L( ^5 b) bset stopped? false]; h4 T+ a& h: S5 A7 ^. v) ?; d( h8 k1 X, H
[set stopped? true] 0 P% I! c" g( v& f: z
] |
|