|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false R" k6 U% z1 Z& D
to go
" x) ^" e m+ V" v; c7 E, jif not any? turtles with [not stopped? ] [ stop ]
) `4 h* u8 e( T1 Eask turtles with [remainder who 5 = 0] [
7 x \1 W+ s2 T% d6 Bset close-mates (turtles with [self != myself])with[
0 a4 p2 w3 U3 S) Y5 {$ m( {(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 ~% X: K: L- E
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 f. `' |+ `3 V! Land remainder who 5 = 0 7 l5 F+ t3 A, w% R7 F$ D: i
]
3 h& z$ a$ c* ~( L O* Q. h$ s9 lifelse any? close-mates
7 @5 {4 j% x O/ Z[ ; v- Z0 E: W$ _; z
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" ?0 i% b: {& l4 e
face closest-one5 L! D. S2 t: y
rt 180
2 a2 D. D [; ^. O- H6 I0 Sfd random-float step-size- d6 r0 t8 H- ^$ L1 [0 L" Q5 e; F
avoid-walls7 ?$ S# `6 P9 w* ?; m, x& c
set stopped? false]
% H& `+ K$ G. @& N[set stopped? true] 8 K, R' C2 ~" j
] |
|