|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& x/ P( J( i$ X( D! m* Uto go
2 `! E) j6 S. B4 U. b5 K6 pif not any? turtles with [not stopped? ] [ stop ]
$ t2 W# m3 M7 ]& k, z5 r6 _5 H4 cask turtles with [remainder who 5 = 0] [
: |3 t3 c3 C/ M' k4 Tset close-mates (turtles with [self != myself])with[
! h) J" \, J/ [$ [, R9 T(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 0 t/ t& Z( \9 i# X0 ?: c* _
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
/ Y' f9 o6 p1 a6 D2 O5 U+ eand remainder who 5 = 0
0 K2 x# K6 _9 _5 ]) d] ( ]8 R' U3 T) D: {4 n0 L. u4 |7 J
ifelse any? close-mates
' t+ O0 X7 C% ~" d[ : u- T7 j8 A" M" z
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ v0 Q) \0 F7 K3 b7 b
face closest-one
9 H& u, @6 I: s% r- y$ z4 c8 prt 180
& n, M0 ^2 L- y% H; A; J" F/ Bfd random-float step-size
) F' k9 A4 C( `5 ?9 @avoid-walls( [4 n; O5 I W! R
set stopped? false]; b* [+ Y3 D2 c# _
[set stopped? true]
& p4 @ d. I+ F+ y: Z6 b] |
|