|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, [. _ b; S" d: k7 G* x9 J# Sto go
7 n5 K7 f/ F7 P6 Yif not any? turtles with [not stopped? ] [ stop ] & c& ^2 f& \' q
ask turtles with [remainder who 5 = 0] [) _- k! t/ Y$ n+ n, L. n
set close-mates (turtles with [self != myself])with[! z9 L: ^! ~1 ^' B; N' w
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) + {8 B t3 R: a3 |
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
) x& F1 P0 f; I7 T+ W2 _. D! u6 G0 Y, t Band remainder who 5 = 0
1 g% D$ u' R/ Z$ C5 o] $ J2 v* W4 y5 H/ B8 r( s2 i. ^. U% }! O
ifelse any? close-mates $ L2 J; j1 n7 t9 I
[ 7 l2 p- k2 r% ]) s4 @8 \
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. q% z/ d/ d* t6 Bface closest-one
4 f0 W4 n0 P9 l. r' M8 }rt 1806 o3 R; n" f" {: K, D; \2 j
fd random-float step-size: B3 j" V. b' k: O% Z
avoid-walls" o+ _2 V( Y2 K( _- I1 W# {$ o
set stopped? false]
3 P% z) d$ i { N" Y. r" z& A7 V[set stopped? true] / c- g4 o6 Y3 x- P
] |
|