|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# M, V0 h: X' ]- `! Yto go; A/ S% d1 g+ G J
if not any? turtles with [not stopped? ] [ stop ]
+ h! ?8 W0 M7 Q: A: F) B2 cask turtles with [remainder who 5 = 0] [! [! n/ j+ [" K
set close-mates (turtles with [self != myself])with[
/ Z4 Y/ V) p+ i' T7 I- V(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) t" _, S5 V4 c7 Sand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
/ p g$ m% g5 b" Z a: z- yand remainder who 5 = 0
- R* i8 C' o! }] % L# M1 X1 Q% ^8 U! x3 z
ifelse any? close-mates
2 p% |1 v3 v: U1 j3 }[ , C3 b: [, p" r- B; r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* z6 k7 F- P3 R- g& h) x Z& Z9 mface closest-one7 E3 ^( N7 P- K
rt 180
K& `& \/ j7 B+ M$ b: }3 F/ mfd random-float step-size
2 Y0 M$ y# B% Z, @: Z1 Mavoid-walls0 G/ a8 x( F: \4 w5 g/ m
set stopped? false]. p$ t- A a- u- T) N
[set stopped? true] 7 v7 V! c7 e% z
] |
|