|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% L6 K# f3 u: ~
to go# i" H8 T8 U; m0 G6 r: @/ i
if not any? turtles with [not stopped? ] [ stop ]
" k, L6 [& R e0 c8 f# uask turtles with [remainder who 5 = 0] [% s" O$ _$ z9 ^% X* y6 D" t) e
set close-mates (turtles with [self != myself])with[
% w7 V0 K7 P/ U4 y& r(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
G9 n' E; X! f$ C# Uand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: l1 h# S1 S/ u) r8 s; G& p. aand remainder who 5 = 0 . a4 a( u6 N: R% w5 f
] . w. {3 N8 R4 P& }$ d! R
ifelse any? close-mates ! B0 O* _! A; u8 t0 Q3 a, b
[ 2 B7 o+ w1 H+ L* `1 s6 P/ R) i5 V D1 O. Y
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
% J! @/ s1 p1 G/ }face closest-one- m; F6 v m0 r2 n1 l3 s
rt 180
8 X4 m( H2 T/ p: Dfd random-float step-size
0 P/ S3 |9 T* }4 I8 Favoid-walls& C$ X6 @5 B* i2 n6 |
set stopped? false]
# q6 z8 N, b- S8 V/ T) O1 Y[set stopped? true] 6 A$ C% W4 `$ o# {
] |
|