|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 b, R6 q; } x+ L
to go
* \ v9 l! S3 s" N, |8 vif not any? turtles with [not stopped? ] [ stop ] 8 ]7 o9 C3 k2 [8 w( i/ s; K
ask turtles with [remainder who 5 = 0] [/ C. G( S* K% C* P l* }9 l+ a
set close-mates (turtles with [self != myself])with[
9 W0 X6 E% D4 U: X/ T9 Y! r/ _$ b(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 2 I/ J! e$ ~; `7 z% C* v0 p0 T
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ( J; ^. t+ w% U, W! \' l- Z) U8 h
and remainder who 5 = 0 " X& q* L! H- Z$ A( N$ [
] 6 G3 G- X9 N# \3 E/ Z
ifelse any? close-mates ' m! L& [ X+ l" d- |
[ ) G5 u9 A5 v6 h
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: u9 y; b# j& }+ `3 `face closest-one9 T. e5 @' M- [$ c$ k
rt 180
" K4 O, f ?0 X; S9 S. @ d$ [fd random-float step-size5 J7 }5 `$ O% b; a! ^- I1 G
avoid-walls
% T1 C c' Y/ Q/ t* Xset stopped? false] X A+ G: U- a. H) Q( r# y5 i
[set stopped? true] 1 P1 m+ z$ n& [9 Z8 l7 Q! D
] |
|