|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& R) g. z4 ^( bto go
- g7 q1 |" q2 _5 Dif not any? turtles with [not stopped? ] [ stop ]
' ?$ f. F( j9 kask turtles with [remainder who 5 = 0] [, X$ T. G+ j1 j5 A. g% {' N q" a
set close-mates (turtles with [self != myself])with[
" ]- O5 Z; r% N9 a: v(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 6 ]" `- w& |$ N6 a& `2 e* h; `
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
/ U: R. D6 w' @8 z/ y z* W- Uand remainder who 5 = 0 $ Y6 z1 T* \7 p$ E) X5 G1 ]+ Z
]
6 `" H+ o; v5 R- D% S7 difelse any? close-mates " M; U7 X$ C$ O
[ ( y& _. o: y$ X* a
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
% V# ~0 O# }* p( ]" t: _1 H mface closest-one
$ l, K% H2 y3 C; L7 wrt 180
7 H9 l+ d9 C- j- R; efd random-float step-size
2 ^) g. V$ p$ o j" W7 _avoid-walls
% Z: v) Q4 s& n4 y jset stopped? false]: X6 m! ], ~5 O* }
[set stopped? true] 2 O8 |1 u8 i4 s! a
] |
|