|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: s7 \" \- N; ato go/ a' u: z4 D4 Q' _1 O5 t
if not any? turtles with [not stopped? ] [ stop ] ) x# |7 A$ R$ x; t- y3 C- \
ask turtles with [remainder who 5 = 0] [
9 v4 [/ @3 Z3 k- }4 R6 g9 Aset close-mates (turtles with [self != myself])with[7 z3 @0 y4 n& ?2 A1 u2 D
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- `( K6 k1 V6 E/ U0 oand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 Y9 [1 I1 I' q+ a, F
and remainder who 5 = 0
7 l5 R+ |: I1 w0 t]
' K% U* c4 J e/ B- pifelse any? close-mates
8 M4 k3 H1 q6 C* u; `. E[ 7 ?% }1 C+ }! T) D5 k$ B
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]. \. P. W" p% M# k3 P
face closest-one
/ {! ]9 o6 n4 m; u: p1 s5 s5 Prt 180
4 H4 c3 d# l! D$ N% {2 s5 c7 {9 kfd random-float step-size
, S3 ~) M- l8 Aavoid-walls: g& p1 k: O7 `7 W2 b
set stopped? false]
/ E5 K7 t! F! m* f[set stopped? true] ) X5 B l c' v D! y, v# W
] |
|