|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: m# }% {& c& X2 L) @( E: I! g
to go
# i% S n' h y4 e3 m" T) ^if not any? turtles with [not stopped? ] [ stop ] ) z* `4 R3 n% S# |' ~3 L
ask turtles with [remainder who 5 = 0] [
( r) y! f9 [( r- c) g) f5 k1 cset close-mates (turtles with [self != myself])with[
1 i9 Z* Y0 Q2 m2 `/ d(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
3 x2 x; o3 N$ T: Xand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
0 }1 Y1 C8 R) f* J& I E, Kand remainder who 5 = 0 v4 h. R" M5 S# Q( z& E, w4 F
]
# m9 E& ]% v" N; R* Uifelse any? close-mates # d E6 p8 B) I9 y7 L5 _% g
[
) y; b& J7 ]1 y$ v- w3 T& B, yset closest-one min-one-of (close-mates with[self != myself] )[distance myself]: p7 l. @5 N" R) L
face closest-one
; m% ~$ ]- N7 A0 [( [rt 180
' S% W& R- @$ L; Z! \7 Z" i2 kfd random-float step-size5 y3 s, `% k+ O. c9 r
avoid-walls4 y- {1 X. G% I
set stopped? false]
- T7 S2 \; L* m: L4 G$ l[set stopped? true]
5 [( ]$ Q$ ?0 f9 {; {+ Z; U3 }" a] |
|