|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& o8 y: D* P* u/ ]to go- s y: ?6 N( }# Y& M
if not any? turtles with [not stopped? ] [ stop ]
5 q& `9 j- c0 c9 `! Sask turtles with [remainder who 5 = 0] [
- U- g2 L L+ y V' X( Wset close-mates (turtles with [self != myself])with[, g3 |' \3 d* c2 }8 F
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
: w! P3 @- ]) q5 ]and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 Z0 i/ n# e9 [/ ]) f
and remainder who 5 = 0 9 d6 c: k9 x/ M. `" ^, M' k a
]
- n6 P- s+ ~4 G- s' e. l$ s+ rifelse any? close-mates 1 a; V7 F7 N% _) l% W3 \
[
' z3 Y& |0 n+ u6 U* T5 K# R8 k5 w$ xset closest-one min-one-of (close-mates with[self != myself] )[distance myself]0 u. |- I' }) d) ]
face closest-one
5 k6 n; D- Z+ D- A3 frt 180
% I! ^- ?$ l2 ]& e" ffd random-float step-size: J1 F6 D9 q: H4 a8 N
avoid-walls: ~, H# P- \% @: G& M* |; K
set stopped? false]
2 s! m" l1 h; N0 C[set stopped? true]
0 R. e6 ?; T" x& Q9 G" P] |
|