|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 I# |) t% X" W) H/ ?! Y" H3 k
to go8 D0 B1 N% |2 i( Q
if not any? turtles with [not stopped? ] [ stop ] + \( G6 Q0 L0 G9 \& s
ask turtles with [remainder who 5 = 0] [
" M0 _/ R- _% mset close-mates (turtles with [self != myself])with[
' _$ R: F* z0 I6 w/ }(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ h: A+ B" D7 e) uand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ Q: B' g) A# n* Y8 s1 Kand remainder who 5 = 0 ; l7 }% Q9 @5 L# S/ b+ A# M6 U
] 3 N* N% p+ L+ `+ V) ?, l
ifelse any? close-mates
Z% j4 E4 U8 a& Q% ~[
, P' f' C+ D1 ~set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 {9 V7 I9 I" N% L( tface closest-one3 ^6 G O5 \% G6 W/ b' V8 A
rt 1800 q }; N% i8 E& u) v! ]( J$ z/ Z% A
fd random-float step-size
7 O5 l. Q$ w, n3 t+ U$ A8 i$ I" k1 l, navoid-walls5 Z [7 S. \6 ?$ B, A8 Z; D
set stopped? false]
4 I; O/ B0 g3 U( A[set stopped? true] 3 ? `* n+ I$ `' Z$ @
] |
|