|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% u" G7 L1 z& V8 f/ W! h9 l
to go9 x* L$ |8 e9 v9 l) o1 S
if not any? turtles with [not stopped? ] [ stop ] 8 ?6 @- y5 ]: c' C2 Q* L* F
ask turtles with [remainder who 5 = 0] [8 H* I# i# _2 X3 \, U) f5 o
set close-mates (turtles with [self != myself])with[
7 ^2 e; m) X, c+ p(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
: u6 _) }8 R4 l3 g, o7 K7 s8 vand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " w5 a* i8 |+ }. y6 s
and remainder who 5 = 0
* }9 \+ f5 K, K0 Q* p]
; w7 Y7 m% Q- t3 c" u( Zifelse any? close-mates - ?" ~" E# x6 N3 y
[ $ y3 [ c; o) E% r# x
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- u0 W$ T) F# e: J
face closest-one
: a/ }6 }/ c0 i* C2 v0 E- grt 180
- H! [6 c U0 p3 U* }' E9 I. z: yfd random-float step-size
! G- W& v/ s: j: Zavoid-walls
7 g7 g; e/ C9 Z; t/ U% v7 X Vset stopped? false]
& z3 K# M8 e3 Q( J' x$ u1 f! g% g[set stopped? true] K$ W' j1 ^* V- ?9 Y
] |
|