|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 H1 V# n5 _6 d7 x# {8 ]to go. R. ?( I$ q4 y
if not any? turtles with [not stopped? ] [ stop ]
c$ S# o1 ` h9 u( i9 _ask turtles with [remainder who 5 = 0] [0 E: Y) S8 S* B( {' @5 J
set close-mates (turtles with [self != myself])with[
3 o, y: k7 B9 v# ?. ~0 Z(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - r( g' L9 `6 U& k
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 5 t0 O7 Y, l; E" Z# b/ x
and remainder who 5 = 0
6 u# u; F7 p9 F* [* A] + D! e( j1 q7 u+ U' R
ifelse any? close-mates
% ]0 V1 _; C7 b# j+ g" W* w[ . C1 ~% f$ K* L# c3 W4 s, Q* G8 o
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]* n4 U2 R e1 o
face closest-one
. ?# {+ u, k) v0 p8 |6 Zrt 180+ g4 g. \ r) u* _+ L
fd random-float step-size
# G% S6 q& E: V& P/ ]& _avoid-walls! m" H7 J0 _ [! r" c
set stopped? false]- t: ~$ j: O( U! c8 T' Q
[set stopped? true]
3 C5 O8 @# U8 |: T) D0 M7 O( f] |
|