|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) G9 K0 @) b, d$ _to go
8 }* f2 P( @* y% p( eif not any? turtles with [not stopped? ] [ stop ] ! K7 E; c& j9 A) {' ?1 `
ask turtles with [remainder who 5 = 0] [: N% q' \5 h( @+ x& e5 N1 ]
set close-mates (turtles with [self != myself])with[( [" k, O, f1 F+ D* `$ r, }' U
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 U6 _& t6 @4 ^3 ^( Land (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
0 u; k2 r3 B3 V# H4 L7 Q* j( ~/ Y$ Kand remainder who 5 = 0 # q" u- m( D K, I5 U
] m3 o2 {1 X: |
ifelse any? close-mates
1 a+ b7 U- S7 J; a& y0 h[ ; H/ P# k- I+ k* G; f
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]* U3 ^- G* R2 G/ J
face closest-one7 X# ]8 s2 k. y3 m8 [& b# ?. s
rt 1801 }+ _* @( I% P: f# Y
fd random-float step-size% i; {1 i! l1 M$ |
avoid-walls7 K7 Z# t& s. ~7 U* E9 a8 z$ f
set stopped? false]
: |7 y) |5 C. j[set stopped? true]
9 C4 C6 F5 l! f- K7 \# o] |
|