|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" D7 q, X3 \, sto go
# x, x1 o! ]& o( iif not any? turtles with [not stopped? ] [ stop ] 7 ~9 O$ |) v9 c; R6 q0 C- Q
ask turtles with [remainder who 5 = 0] [! F: C+ n' y& A* o! x2 G8 |0 s
set close-mates (turtles with [self != myself])with[" T: u% f+ y" ]2 @/ j
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) * r% ^+ p+ d) M: [. x; i% M) C
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: y; h: W0 V- W; O3 a, l" m' n g1 ]! }and remainder who 5 = 0
. e7 Z2 O2 v# A l* H8 K* j] " q! \& _- a8 k: i
ifelse any? close-mates
% U* [: d8 G& F. b6 Y) u2 u9 p. x# l[ $ G. {& H$ D! ]6 i) @% q! ~" L$ w
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, Q, y: Y, X, m+ k0 y6 sface closest-one
! g/ ]2 I, \1 g+ |" nrt 180; ?# s3 M4 `/ d' J
fd random-float step-size
, W' F3 t6 b9 S' z" I" X5 Z& bavoid-walls
6 V: }/ C" R8 c6 s: ~set stopped? false]+ m5 G. k8 h0 Q- t/ ~
[set stopped? true]
+ T. o* T/ t7 P] |
|