|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 t) y o& e3 s" S, rto go
: C4 {' E. M) `' ?if not any? turtles with [not stopped? ] [ stop ]
$ E( u/ E2 v: a- R0 C2 `+ k, @ask turtles with [remainder who 5 = 0] [
: L& @0 f! a) Rset close-mates (turtles with [self != myself])with[/ T2 K2 h& c. |
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 a' ?& y8 }$ k( T8 O) ^
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 m0 A5 ]$ B9 c
and remainder who 5 = 0 : Z1 _ ~, t% ]9 ^, l; r3 t* z' g
] J3 z& `% U& u9 g- |7 \5 s0 s& k
ifelse any? close-mates
- f3 S. v) A5 D[
- |. T! _, C6 q. j8 w& U$ N- Aset closest-one min-one-of (close-mates with[self != myself] )[distance myself]& u7 r6 P: U! S! K
face closest-one) Q4 ]' o3 a1 a4 L7 v, K
rt 180! k+ j% w8 e% b: G* R, @% g
fd random-float step-size
$ O( P* w' ?. H/ C) p: [9 eavoid-walls
. i4 L* q2 H6 y( Oset stopped? false]$ z/ Z' e7 U5 l6 F# b% Z5 H# W
[set stopped? true]
) ~7 S0 O8 ^! ]2 Z4 ]1 m] |
|