|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) Y# |! c6 k5 o7 ^* m, n6 z8 yto go
+ o: s) s: V0 c7 R" }/ aif not any? turtles with [not stopped? ] [ stop ]
* l! c7 v' [* k7 \4 l2 Cask turtles with [remainder who 5 = 0] [, p1 h5 D; f* v2 G/ ?% o7 [
set close-mates (turtles with [self != myself])with[
7 w& {: I0 W6 y" S# V3 A& ^(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 e5 H5 |% E. t8 b0 i8 }: _& c* j
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% W3 x! C- E* Mand remainder who 5 = 0 3 a) h# {" V/ p, d
] + S5 G, g, @: l2 A) k( ^ l
ifelse any? close-mates
1 ~ }6 i4 z2 b[ - q& y( H+ L1 V4 R. Y" u8 r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself], Q3 t; j/ ^+ x7 u3 v7 Y
face closest-one7 g2 J2 a6 k$ L. v7 d" i
rt 180
6 k0 A4 D' _; mfd random-float step-size
; G" {/ ~7 j( u1 I6 Cavoid-walls
' I/ D% ]" x6 t9 l* n7 v% s/ s* kset stopped? false]6 [$ B; v' D& \0 n- Y5 P0 J
[set stopped? true] ! B4 F2 g7 r. r- \/ {
] |
|