|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 Y- u5 @" H% e' E( ato go
2 Q& i, Y5 v' q8 z- l& }if not any? turtles with [not stopped? ] [ stop ]
0 d8 X6 n+ D( task turtles with [remainder who 5 = 0] [
# i0 t" `+ \9 {0 Lset close-mates (turtles with [self != myself])with[
8 Z+ S5 b( d9 @% w1 u, {/ q(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
' m9 f" V0 G2 _; S* H- pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 p1 O) I5 M ]2 J
and remainder who 5 = 0 % h) j% \& _ }$ A
] 4 n' t- K: a% _# l4 @, d& S. b
ifelse any? close-mates
4 D0 a5 f! H7 y1 b, Z7 k[
$ ~- e% J0 I9 U& o* k. Wset closest-one min-one-of (close-mates with[self != myself] )[distance myself]2 d& W/ G9 t! ]4 F
face closest-one6 d5 H& F# p: ~, y) D
rt 180* {+ K1 y- O, m- Z: W `/ v
fd random-float step-size
, ]; l: _3 l: xavoid-walls
, P: H# N8 t$ U+ n1 D# }set stopped? false]
- T) v2 V$ m6 I* j3 j: y& K[set stopped? true] ; O( C, N2 o% G/ R v# N
] |
|