|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false( K$ K/ w: r3 {. f) D) Z( m
to go& o% l& R3 r- e
if not any? turtles with [not stopped? ] [ stop ] : }- D$ z, l$ E" q* K, A
ask turtles with [remainder who 5 = 0] [
) q1 k) v. T! K9 F. y( V* mset close-mates (turtles with [self != myself])with[
- z A, w D0 T7 p; P( e(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) % j9 C2 T* I& w9 `7 q% K, v
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
- k* [1 M7 N @0 N8 O0 mand remainder who 5 = 0
7 W1 x3 z: e5 ]] 4 a: D0 N1 w/ B: j9 c4 _ l; N
ifelse any? close-mates % d3 |0 I& p: Q4 [1 c' c5 s7 D
[ ! H5 n% a& k. D7 A% f
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]# W4 c! f8 r2 H
face closest-one& T# M1 g7 |( l9 L, ^
rt 180
" C6 ?2 f& {: ]. ^! K6 n5 yfd random-float step-size: k# \4 w8 j& g6 c1 o$ D
avoid-walls
' t. F( C* s0 y$ U0 l9 [) vset stopped? false]
) W! c- T5 J0 P( r) {! b( @. g* C[set stopped? true]
3 O. A! F; s$ g/ b- B" @3 |] |
|