|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" L! U7 C+ g- u) c/ o- o
to go- ^+ l1 K, [6 [- \ H, r- H6 v8 u
if not any? turtles with [not stopped? ] [ stop ] 0 ]7 U4 n+ Y1 S
ask turtles with [remainder who 5 = 0] [
) V, t* f. {$ W2 y! Z8 d7 z8 Uset close-mates (turtles with [self != myself])with[
/ ~% a6 @4 A' i& N(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) _5 {3 W! b7 Q4 G% s, F T0 Vand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 K) I: M9 f) D% Oand remainder who 5 = 0
* W: B* ]: s- r( H1 c8 [] $ V% m7 ^, e' i$ W
ifelse any? close-mates , u0 a. [' [ Y
[
6 L$ S, F: Q- e) k8 A2 ~; \set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
% U7 i; ?3 P- O$ e3 I S& {face closest-one. E8 s9 \4 i* B& Z/ Q4 r* `
rt 180* C& Y- K% p+ _" g3 E! i
fd random-float step-size$ S0 E& |1 n m1 Y
avoid-walls
8 O7 w- X) X( Oset stopped? false]7 B# X" O. P" h B0 [
[set stopped? true] ( o5 k% e3 z1 p& R9 F
] |
|