|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 {, ]/ I& }4 x D9 _
to go$ d, o( O- E4 F" k4 I! u* k: n
if not any? turtles with [not stopped? ] [ stop ]
$ _3 v. B' v' lask turtles with [remainder who 5 = 0] [
7 L; k* m5 z2 f, ]set close-mates (turtles with [self != myself])with[
" j! h1 q0 N5 s) e( o; [4 m(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
8 e% F' Y B$ q. n6 ]$ @. ~" rand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . ~" s. Q5 F( w+ I; u
and remainder who 5 = 0 * m, h& Y, @) x
]
6 _0 }- E* \& i8 N0 W) zifelse any? close-mates
# ?( `3 r( a# ~1 w5 U[ ; \. X8 p6 ~+ U
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
; Q; i/ T1 J& P# O; Rface closest-one
9 [8 C. X c( l' u/ x) E) G; b9 a+ h5 Wrt 180+ |0 P' E; m$ s7 V) Z* U! `, f
fd random-float step-size0 S/ a3 t5 E/ r% g) B9 G5 t* w
avoid-walls2 X z* W( `: E- {1 |! |
set stopped? false]$ O e5 |$ \$ @7 T
[set stopped? true] + B. Q4 N+ t% c4 x* M
] |
|