|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& {2 X1 N$ ^2 x) n2 y& S5 l0 Nto go8 K0 ^3 t# W6 c/ h: u% y
if not any? turtles with [not stopped? ] [ stop ] $ Z) h0 E% U) ?! J B i
ask turtles with [remainder who 5 = 0] [+ X9 G) F2 v& {6 Z- V4 g6 V; q
set close-mates (turtles with [self != myself])with[. L! ]8 {- w* i/ C6 P: t( B. v
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) i2 w; G( C0 k u7 w6 R" H- V2 wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) R8 f( G& S* l$ A n, e
and remainder who 5 = 0
7 L) \ Q! a+ G* T$ Y] , Q. |% B/ W. L4 g
ifelse any? close-mates
* c; {! \- |* }" R$ H! L2 N9 g[ ; a% k7 W P1 ^. B/ N( z& d
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' u+ C4 Q$ t1 } A& X5 W5 O: gface closest-one
8 _. Z; `% ?8 V3 yrt 180
- j0 Q# y$ w# r% r5 E& W7 Vfd random-float step-size
8 f4 U: e H, g! ?avoid-walls
; B3 e7 I. }0 n' @set stopped? false]
# I" s+ U7 d. c5 C: d5 v1 h[set stopped? true]
( f) h. x' [* g; p% S) q] |
|