|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ r# s7 O- S' M3 c
to go% K; }! c$ ?# q& l" e7 j9 w
if not any? turtles with [not stopped? ] [ stop ]
9 h. Y/ e) i* H# W/ B; U: k! lask turtles with [remainder who 5 = 0] [
+ b4 U1 e$ c$ U$ H$ S" f/ Vset close-mates (turtles with [self != myself])with[. i, w# f8 C3 I0 ]+ z* t+ y# M! K
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 d% k, Y. Q! w1 y4 i
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
$ ]8 v# g) h0 q5 S/ y9 Fand remainder who 5 = 0 ( D0 e9 \# v) y: d) h6 r6 z
] : H' H6 I" z f; s. H7 c1 s
ifelse any? close-mates
* G9 n% V. \: p! B( E[ 7 q/ {+ Z4 g- ?
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 U; i3 s5 t8 y* u% Lface closest-one5 R. t8 @1 a! d- ?4 I
rt 180# X1 Q' x6 O I
fd random-float step-size2 }! r, ^( A- Q
avoid-walls
* D8 v+ [- I& p/ b% t4 _ z! Xset stopped? false]
5 ~7 E; B8 o' [' l# j1 y[set stopped? true] - l9 ]* T! O1 K+ l3 I
] |
|