|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
S) j0 I5 K$ dto go
: f: T7 ~" P/ S8 s! Rif not any? turtles with [not stopped? ] [ stop ]
# ?" k% }2 H4 @! dask turtles with [remainder who 5 = 0] [
; o9 M, g' h+ [; D# vset close-mates (turtles with [self != myself])with[1 `+ ]- y3 A: U8 k
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) . D* L4 r, b* l$ T7 N: E. v
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , O3 q5 ?- k S& @6 e/ K. w0 i& @
and remainder who 5 = 0 o! v& ^0 w) M* [- B6 m# _+ j4 O
] * Y0 a7 Z' t; D2 J
ifelse any? close-mates
$ Q0 T( q* L$ d7 Z( S& {: w' ?( ^[ 1 N2 _, w: H9 U" X& H3 ?
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 [% e9 j6 r! y9 d W2 kface closest-one \5 O5 C r5 k8 u
rt 1808 O9 D% z+ A% H4 u5 W2 _2 S4 i( k
fd random-float step-size1 x7 A. P( V7 z6 e) g, D6 e6 P
avoid-walls
9 u: F0 H8 g7 O0 xset stopped? false]
% j U6 y# |' C) W) k2 b; I" J" r[set stopped? true] 7 l! L% W. E# {# f2 ?4 K
] |
|