|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ R& f c, C) w6 K3 h2 c! v2 M
to go
$ y; I( U3 Z3 S4 n/ H# V8 b& Z6 zif not any? turtles with [not stopped? ] [ stop ]
2 C) W* }1 w. A$ p8 b) Dask turtles with [remainder who 5 = 0] [
- ^4 Y! w3 k7 \2 ^2 v6 aset close-mates (turtles with [self != myself])with[% ^9 L7 O6 H+ z- u& v7 l6 S$ u" {
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( \. H4 T0 C3 v9 L9 p6 k& ?
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! Z: q9 U' q8 l0 w
and remainder who 5 = 0
# q4 Z, k4 C$ Q2 a) d. M, |] / N, a* Z% d- L! _! B# w& h" A @
ifelse any? close-mates
8 h8 B* v$ \- u" d1 _% ~- P& ?[ * i* N$ A; O+ [, O0 v1 I( ^
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) v3 E6 z0 \% z a/ a1 s, bface closest-one
$ {! \* P0 r6 A. H( c$ J* Wrt 180
& B! c+ G7 n0 A8 K2 p" g0 q) Dfd random-float step-size
% m9 w' x8 Z# uavoid-walls
, L8 D9 k0 m3 Fset stopped? false]
. t& G) u6 j; y2 m[set stopped? true]
* B" ], T8 k/ y0 Q4 a8 \] |
|