|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ N+ e+ c, P4 a2 n7 \
to go
5 i$ O9 I8 t9 L: H [2 `8 aif not any? turtles with [not stopped? ] [ stop ] 6 `0 v8 v2 k) }2 p/ e/ g3 F8 A3 q/ s* ?
ask turtles with [remainder who 5 = 0] [
( }( s4 |* D, p# X+ O4 yset close-mates (turtles with [self != myself])with[
+ W: m! x q6 x+ s! X, \(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; {3 p3 r! e- e- i9 j% n& Iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) & q, g# c2 B$ M: ?+ t. \
and remainder who 5 = 0 _" L& S) Z' m, x5 U- W5 v# l
]
2 i9 B; ]) p I4 Eifelse any? close-mates
6 r7 T( `2 Y7 K! T! V8 S[
2 o5 Y7 G2 E R1 s9 `set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: r8 `. B8 Q0 k; I8 Yface closest-one
; w% @8 G+ B4 `) S T! Frt 180
+ {. ~9 A' L/ O: s4 Q- Y, w1 ifd random-float step-size& d( r6 W! d1 R1 H9 v3 M6 D3 _
avoid-walls
$ H) u$ s' p+ aset stopped? false]
- O" ^) f( b T" n0 Q9 Y[set stopped? true] i% J5 ]3 M7 s) N2 J( ?
] |
|