|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ B" T) a6 `. {+ e. G M- W+ Uto go
. m. a9 p; B, M n. lif not any? turtles with [not stopped? ] [ stop ]
5 D" r; X% i; V$ z n" V2 o) k5 rask turtles with [remainder who 5 = 0] [
6 a3 |6 N5 E0 {% }' uset close-mates (turtles with [self != myself])with[
! K, h' b5 ?* B5 S# ?0 Q, H, B(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 M9 Q& U- V+ T+ Z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 7 j" Q4 H. v% w' o0 C
and remainder who 5 = 0 9 _ N$ P/ v F. h' v& U
] - v& }% T& g: c. L! U! z/ v7 p: B
ifelse any? close-mates
) f }# b9 e1 v6 Q( W7 v" {; ^2 z% q[
% b) ] y) ]2 | b$ Dset closest-one min-one-of (close-mates with[self != myself] )[distance myself]* V1 L5 Q2 k2 M1 S+ l8 D
face closest-one( X- n% L9 W: U% v) @9 ?% \
rt 180
% h2 p; P) u; J. g2 T6 i$ C# Q: jfd random-float step-size1 c9 d$ B/ Z# Y, V5 C# W5 R
avoid-walls
1 I5 [3 D9 W7 F; ~set stopped? false]1 }- z6 ]2 {8 v1 u6 z, y' ]& G
[set stopped? true] ( I0 X* T2 _4 l- U
] |
|