|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* N/ M$ e7 y7 V4 Q& L! r
to go
K) Z3 S0 B5 i3 b# r6 l! i& O& bif not any? turtles with [not stopped? ] [ stop ] , O0 C3 H$ t6 \2 X5 N1 a7 y1 Y$ b0 p
ask turtles with [remainder who 5 = 0] [
C( Z8 _$ u% z8 aset close-mates (turtles with [self != myself])with[* ^' x I3 n1 O1 G; k# d
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 5 H: u1 N( L1 \+ V# X0 }3 K
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) : I9 H5 `$ G* F
and remainder who 5 = 0 4 y* _. H2 R9 a" F: y, g% D ~3 f
]
( t; t! t5 d9 |+ Tifelse any? close-mates
* _9 h4 j" {! P! g+ L[ 9 @5 @1 [: k k& B" P2 E
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
% d7 D- w. p: s- U' L5 rface closest-one+ ~0 ]! f! F7 i( v& d
rt 180
4 E7 i2 g& n# x1 I: u9 \- b* ofd random-float step-size) \/ j3 b$ k1 t: P
avoid-walls9 Y4 k: u1 T6 d* z
set stopped? false]
: j; ], b4 t" U% n- s# p[set stopped? true] & u% T0 i R1 n. R' Y8 d( a: f
] |
|