|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
% @0 h7 ~& F' |+ Ito go
; P K% J# |% d, G, }' [$ \9 \5 ?6 Gif not any? turtles with [not stopped? ] [ stop ]
- y+ `( ~. ^" F) y8 O( z, y6 Sask turtles with [remainder who 5 = 0] [" p( B5 U h: b( f7 H
set close-mates (turtles with [self != myself])with[
; B* f7 i4 D/ Z( Q( W+ @(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* S1 |7 z1 U w7 @- yand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 p5 A8 \* o- J# U5 Sand remainder who 5 = 0 ( l- q, D( e2 f! n, D/ Y
] $ f5 o; q) I! x/ }' @
ifelse any? close-mates
" U6 Z3 D6 o7 f; W8 A: O[ 2 m0 a8 W1 y( B. C' R6 G" M
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' Y1 |$ [* F |# u% O6 Rface closest-one1 o$ x1 I$ Q1 Y5 \7 N/ O, i
rt 180+ x! v9 M* h3 }5 a( {
fd random-float step-size6 `# A N) ?+ h
avoid-walls
3 g% y5 [% A& E& ]3 a0 `set stopped? false]
" x/ }. [! v0 g/ n[set stopped? true]
4 Q( T! e) v: ~" l' L] |
|