|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false( Q) e$ ?/ q# R0 `5 G4 T a
to go$ t# j0 C M* [7 @1 M5 P5 f
if not any? turtles with [not stopped? ] [ stop ]
9 {( ?7 W" y) Lask turtles with [remainder who 5 = 0] [
( Y# g) @1 T& S; Mset close-mates (turtles with [self != myself])with[
- Z5 @5 i+ h: u- l) d: G, _: a% Z(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) + G$ A1 U4 Q0 f* M A, {/ k
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 8 l2 f4 V2 N- @" e; _; U( H
and remainder who 5 = 0
0 |2 p! x1 p; z3 O( V( {] + ]# r2 q1 G r6 S/ _- O, P
ifelse any? close-mates 0 ?2 T4 D& t* ^) A1 _
[
6 G7 j% F1 x9 H, ^6 Oset closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ C" o% E1 G' n: K, ~
face closest-one
- Q$ o' d6 [ f& N( U, drt 180
' M% ]& G, W U Y! j1 g% Cfd random-float step-size
1 o: U( s4 p3 e/ g4 ^avoid-walls
5 E6 ~" m0 `0 r% jset stopped? false]
2 `# B2 ]5 J# P/ p4 G$ q[set stopped? true] . m/ k/ g& [6 x8 b/ T
] |
|