|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false `+ k0 Y9 v' X1 Q4 p) ~. h3 S3 e* k9 ^/ f) e
to go1 G0 E: R" z. G- ?* g8 u
if not any? turtles with [not stopped? ] [ stop ] - j& K9 S6 S: x1 `
ask turtles with [remainder who 5 = 0] [
2 h% h ~# i s2 aset close-mates (turtles with [self != myself])with[
& S' {) d* \7 E5 _, t4 ^5 L& W(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) r+ [& V; C! {- ?6 S3 M, @and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 0 ]% t, m; u# o d, |
and remainder who 5 = 0 , R3 D; f, G% p& P# s: B \
] 8 ^' Y. o7 K8 h+ W% S
ifelse any? close-mates
5 `2 y' }% o/ o0 P6 c- }1 x[
2 n. {/ ^- z' a) bset closest-one min-one-of (close-mates with[self != myself] )[distance myself]" d0 [, K- @0 |1 \5 |7 Q: N1 [
face closest-one+ ^1 L* D4 J! Y9 [7 t! Z3 L
rt 180
/ `- V- o! a% e5 w5 I Yfd random-float step-size r) [) N" S0 q5 ~2 |
avoid-walls
E- R+ _# f, o1 _set stopped? false]$ {& I O L' d) g2 H" F
[set stopped? true]
0 q, q5 G2 i" ^] |
|