|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false/ f8 Q; ]. ^9 s0 b+ ^6 L" o
to go1 a9 r# H' F6 v/ ]$ j/ s0 q1 }
if not any? turtles with [not stopped? ] [ stop ]
$ @% U- w5 F2 `$ q7 Dask turtles with [remainder who 5 = 0] [7 O8 o: }+ {: F- W) d
set close-mates (turtles with [self != myself])with[
g2 C' Z9 P) j9 }5 O(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
4 ]- e* {8 |1 V+ }: Z5 E% eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / W z3 h% r! v5 u. C- x6 \1 |
and remainder who 5 = 0
}9 T, Q2 K2 g C0 y+ R] + t; d* S, q" z. m. c/ d
ifelse any? close-mates ! L0 m1 @/ O+ M) i. s7 }4 k0 G
[
4 W0 M& J# H6 L/ \( B/ q) ]set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" u8 C- K8 `% b+ `6 p
face closest-one. J& d3 `' {8 ^
rt 180
! L, b. B) L' t( }/ G$ S, Nfd random-float step-size9 s- W& S! u( O+ E2 O4 l- ]& n
avoid-walls
) q/ \1 w: [+ O7 Dset stopped? false]
3 Q; K% I' j; N, p6 M9 H) _5 l8 H[set stopped? true]
* l. P/ O8 T. C! t3 V] |
|