|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: W. w V" O2 d
to go1 Y: g& f- Q1 n x, m! j6 E
if not any? turtles with [not stopped? ] [ stop ] 0 c; N# [. F- e" _; d
ask turtles with [remainder who 5 = 0] [
. L' O. C% l6 g9 `# g Q O$ F4 Xset close-mates (turtles with [self != myself])with[$ I' |" L. Y# g% E% H Y
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, X. q& ?! d- [3 G6 d$ o: rand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 7 ?7 @$ W; r: p
and remainder who 5 = 0
5 j' z+ _. \3 M, H& I& {, ?]
8 ~, t4 P; r. Oifelse any? close-mates % o L% x- |9 }- l# w* F& T. I* x
[
- U& d/ R# i7 R) ?set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. H+ }% }9 i x3 d+ z3 u) b7 y, Dface closest-one
5 v" o! ?, H7 P, prt 180( S. d' X# }1 |, j1 o% w+ \
fd random-float step-size* r: q1 R0 `; O/ m8 T" {1 t
avoid-walls/ V" s4 K) B5 u% F
set stopped? false]: |* \' |3 ~! \; `" r6 ~0 q1 _
[set stopped? true] 7 X+ o: \5 V z. {- N4 H# t
] |
|