|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
8 o$ D" ?& }& Pto go' t# x( g" {, M7 F) d1 w
if not any? turtles with [not stopped? ] [ stop ]
+ M8 C: e" x+ Y; n5 a2 Eask turtles with [remainder who 5 = 0] [- \9 k( x: E& E) H4 _
set close-mates (turtles with [self != myself])with[+ {% h- W! C7 W! [/ C0 _. u
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / d; G/ v/ ^! J& h/ l# h O7 I
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ B$ o; n1 U; w( C0 w( P, j/ Z2 a. ^
and remainder who 5 = 0 2 ^; a! e$ L" t' T
]
" A5 J3 p6 T1 t% J: W4 C. hifelse any? close-mates 6 G4 @" l+ m/ a$ [. f' j1 L2 {
[ - S8 W. ]7 c( _) `
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]8 k3 h. e3 l% _4 }
face closest-one3 S6 e4 ~% F" @& \& p9 a
rt 180, [) m) Y9 p# e, T C8 j6 n
fd random-float step-size) N0 P t8 E0 F) Z/ _
avoid-walls( ?/ X( z* f/ V: z( A0 Y
set stopped? false]
- I' M, N9 R/ I- \% W[set stopped? true]
. y2 O+ i+ U1 ^] |
|