|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' F" L7 n5 U" Hto go
) ^, a a, C7 H$ e3 e5 ]4 v& ?if not any? turtles with [not stopped? ] [ stop ] . ^/ m& ^' f+ A) A% `" U
ask turtles with [remainder who 5 = 0] [
6 F, e8 `$ e, o0 d: J6 Pset close-mates (turtles with [self != myself])with[
+ }' q0 D2 B+ F& _5 f$ k X(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) . r/ f+ j( l$ n# x8 I
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
$ }3 y* ?! l1 A# \and remainder who 5 = 0
" g- {/ S/ ?& ^3 Z" w+ {1 []
8 g( Q2 M2 }4 k3 F. lifelse any? close-mates 9 ?8 |: k/ R, K, t) A( s9 r
[ 0 Y, h7 z c% ?
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
3 Y0 Z) z% M& Mface closest-one
* i8 C) e: p9 K2 \3 V$ ^rt 180' |2 G. U/ H0 a4 v
fd random-float step-size
, `2 D4 V+ m) K; Aavoid-walls" A L" X8 ?4 X0 Q& D% G7 D
set stopped? false]
* |1 E3 w" r/ i# k+ c1 _0 W) S[set stopped? true]
. G5 g1 }7 r/ @] |
|