|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false; s4 }' V' s$ o) `$ a
to go
$ ]% K, N9 l4 G! }. ^: A. k$ rif not any? turtles with [not stopped? ] [ stop ] 8 t4 _9 f5 O5 Y2 ? q
ask turtles with [remainder who 5 = 0] [
- J% _- T; q% C: Q3 |+ fset close-mates (turtles with [self != myself])with[
_' {4 W7 Z$ l; i(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) # Z6 ]3 w/ b' P7 P5 ~
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 1 L9 `* Q8 F7 i$ j8 X
and remainder who 5 = 0 % ^+ q, J/ c. L. S) a) s; G
] & g1 K: x" R( d# m0 E
ifelse any? close-mates $ u: n% k P& l4 j3 L. A
[ % \/ O t1 Q/ E$ R, [
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
7 J4 g, i$ A* a9 @face closest-one
6 u3 I* ~' {$ t: l1 R9 ]2 e' a2 I R) Z; J/ Jrt 1803 x( S! Z6 c0 [5 W- j0 m' t
fd random-float step-size
# F! c$ c( L$ u3 Q6 d! ~avoid-walls
( T2 Z7 ^% [: fset stopped? false]* T# o H+ x5 t' ]; e
[set stopped? true] 6 U4 b; h' [& |2 Q0 L0 X3 s
] |
|