|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false7 X: d3 Q( ?; d& ?, U
to go5 w- M) \; a3 [/ P2 q& r8 I
if not any? turtles with [not stopped? ] [ stop ]
1 c" T L9 P Sask turtles with [remainder who 5 = 0] [
9 I0 N+ c6 m$ C. w3 g$ H+ Iset close-mates (turtles with [self != myself])with[
/ k3 @' i6 ^- `. g& v% A) R; q6 ](abs(xcor -(xcor-of myself)) < X-Dist + Wid ) $ Q* m0 n/ G. m3 q. o$ N) Z% B% p
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ E4 y3 d* o8 t% O7 i9 z/ s+ J
and remainder who 5 = 0
5 p+ y. i+ E+ ~7 y: z) u0 m7 v' }] 7 T$ e+ Y! @+ P' d% q& J) ]
ifelse any? close-mates : Z/ o- F1 I/ @+ n; D [2 n
[ 5 L0 Y7 M \ W/ E
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: c- s, G [4 i( U# X: }, tface closest-one a. p J. R/ J
rt 180
1 y& O( G3 M+ T& bfd random-float step-size5 o8 D4 U1 T1 t" C, J! g1 m$ Q; o
avoid-walls
$ G6 x: Q9 Q8 J7 r1 U! I) Y7 Fset stopped? false]
- m( t+ L5 y% L: y6 m, n[set stopped? true]
1 b! F& ^! T3 r$ T2 \] |
|