|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ U: B4 ?+ ~3 l" B7 y1 Ato go( Q& D& a7 V2 {/ _
if not any? turtles with [not stopped? ] [ stop ]
]& N" C: `- T. H! D5 k; ]ask turtles with [remainder who 5 = 0] [3 x' U& s" Z8 j4 {
set close-mates (turtles with [self != myself])with[, X& E! X% v; F( a4 I' v W
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 s8 P+ h9 b+ X
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 B! `! c; p& I7 Q) J
and remainder who 5 = 0 , y) ^% X, G( A' Y& a7 l
] ; r; L. e {) m, h5 `4 h! [/ n
ifelse any? close-mates
1 f- M# r/ ^' Z! U8 k[ ! U/ ]/ e; {+ x6 y& `: o
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 L, }* X2 `; f5 @* h1 K' x; qface closest-one
; Z! o( u4 H: w* p% ~- mrt 180
7 h: f3 y8 s: q* F4 @; \fd random-float step-size
- [2 W* N0 g6 G4 a* j5 S$ Zavoid-walls1 N1 s' d! u. c" J3 |: r
set stopped? false]
$ v% K+ |* n% z) `[set stopped? true]
4 E3 q) l0 R+ o Q] |
|