|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
+ H: T! x' f# q' E* l+ fto go
6 M* T2 J l5 M8 v5 hif not any? turtles with [not stopped? ] [ stop ]
$ c' k0 w5 p- t/ _* G8 Yask turtles with [remainder who 5 = 0] [
' [3 |( v \# F4 \8 E6 s, [set close-mates (turtles with [self != myself])with[
8 I. f ^: }2 ~(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 u/ u, c8 P. _ f8 F! Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) Z$ x2 j, f4 \9 \, y6 I8 y' S4 a
and remainder who 5 = 0 : P. n E7 A1 h8 K
]
) K: n& U) J- ^* ?- r. Iifelse any? close-mates % A. r7 a0 b1 u0 l( T
[ 3 r* I; P. A& ], X
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
1 e: f7 H3 r9 X- U8 N$ vface closest-one* I/ [* |) D' n- v" H
rt 180
" h5 w* l+ a- Cfd random-float step-size) z( T+ R0 n) a
avoid-walls
* ~4 z* u7 H* F. s' V9 Xset stopped? false]" ]5 w5 i0 ?* m( Y
[set stopped? true]
) y/ i% c( `7 K) L] |
|