|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 _% w1 I# ]& A2 U
to go
) t1 V+ w! s- D( xif not any? turtles with [not stopped? ] [ stop ] . z5 P: `$ {9 y% `5 I
ask turtles with [remainder who 5 = 0] [# w& m- V) ?5 H$ J2 L5 _
set close-mates (turtles with [self != myself])with[
# \* a) p0 E8 R2 \3 n- W(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 F% B/ a( p. L0 Q, K" }: e" n0 }
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 6 A; s3 I! A. e! }( K. e0 `1 ~) P( P
and remainder who 5 = 0
, {, o I0 d9 |6 O% ]- t/ U]
/ j) B8 m$ Q7 n/ n. o( rifelse any? close-mates 6 D) n0 `, k4 b) A3 c5 K. u+ e' |
[
' R N: l( g9 D4 ~; T1 Rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 W8 p/ O$ i( \8 E, L; ?6 `
face closest-one
1 T( r5 M+ ?4 d4 krt 180
" C6 D# K+ a1 q3 T1 n6 R3 {fd random-float step-size
- B2 s2 A3 O1 N% Yavoid-walls
/ F( _5 t1 X( W2 t) K5 S3 qset stopped? false]
/ V% e# v" u1 r$ s) m; D8 m: w[set stopped? true] 2 T1 s* b* L G. P9 S" U* \
] |
|