|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
. t' Z) Z j, M: @& ?4 Nto go
) H* Q ^% n' _; ?& I. G: V. ?7 Cif not any? turtles with [not stopped? ] [ stop ]
" s8 B9 q2 a( ~ask turtles with [remainder who 5 = 0] [; t/ m/ N' G" W0 S1 G+ Y4 h( m& k
set close-mates (turtles with [self != myself])with[$ q" L2 x9 i: I5 S
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
r, L. [5 I1 ]# |and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
# Z5 C6 l* h) g5 n# ?$ O4 T V3 Zand remainder who 5 = 0 9 O6 q/ [1 J- z: y' ]& N
]
, p- N0 S4 F5 |3 ~ @! ?* jifelse any? close-mates . U- I3 u8 h5 V5 B; }
[ + z7 O& y2 z4 L
set closest-one min-one-of (close-mates with[self != myself] )[distance myself] G' `! q. |7 k$ x
face closest-one
@" s+ j# X5 q9 ]6 x, }( krt 180. w( E' z$ K# G9 O; O t' {, G
fd random-float step-size
4 y; j5 J) V% a: g" tavoid-walls& d% X$ Q( \/ ]
set stopped? false]
6 d; h) G( \$ `6 Y1 ~/ B[set stopped? true] - _$ v' o# P4 o5 R6 y9 S
] |
|