|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! T, f0 T* c& k( [" C( B- Ito go g. g) g7 E8 d5 C
if not any? turtles with [not stopped? ] [ stop ]
; D9 d; s1 c3 Z6 j7 Vask turtles with [remainder who 5 = 0] [
, \, o/ Y% l- F9 {+ _set close-mates (turtles with [self != myself])with[
/ A: i! W5 Q0 c$ H: U* |( t* J(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - g j' j( b2 b/ P4 Z. \, H9 s5 a
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 8 ?1 S! v6 l: u' U
and remainder who 5 = 0
8 L( b7 V, s7 F3 ]. c9 b2 l] 2 n! c7 f2 B8 d$ J8 Q& M6 @
ifelse any? close-mates
" c% U. V. i1 m; _[
1 { y& |+ K0 j/ j0 fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]4 c' e1 K$ d7 H8 B
face closest-one
) K+ @5 F* J$ Hrt 180# f: U- E$ S4 s7 ~+ _# u
fd random-float step-size$ K: x8 J5 J# G1 S: G4 {4 L
avoid-walls' j4 e2 x2 V" }# v7 B
set stopped? false] O6 G* U1 P$ F4 a9 f9 I+ s# k
[set stopped? true] ! J- N2 E" c2 h, U! C
] |
|