|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false4 e" g( ~/ ~. C% o, p* H
to go& Y' D0 w4 b7 V9 W
if not any? turtles with [not stopped? ] [ stop ] ( F; ]5 C( M0 `( u, Q4 p- B: v0 P
ask turtles with [remainder who 5 = 0] [
# d N* T# F" {0 X0 }% u6 Sset close-mates (turtles with [self != myself])with[" K* [! ]! H5 |8 E( Z% H1 w, Y
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) . v; d; x) H, v3 W
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( i5 L2 F9 v4 m/ d- t2 land remainder who 5 = 0
7 w0 S8 B' K0 t3 v( V+ c5 v3 u2 r] 4 n% a" k: m2 D. @4 w, ^ b
ifelse any? close-mates . S: l5 E2 ~9 o$ H A% |- ^
[
8 t! g) h5 ^2 k& W) l; kset closest-one min-one-of (close-mates with[self != myself] )[distance myself]' W1 r. R& G6 @" C$ {: M& D
face closest-one9 q; P. N/ b) b( h3 Y
rt 180/ M( m5 K& Y# k& d3 M+ l& K
fd random-float step-size
" N; a1 q: R c3 T* ]# t7 lavoid-walls
: O! H3 E6 [, r. U7 Mset stopped? false]
# N# ]- z2 w' G9 z9 w& R' w+ a+ E[set stopped? true]
, E! m6 i# y1 t$ q% K] |
|