|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
/ A5 Z3 f. N8 N# t0 Z* qto go
9 s! O1 q* l Nif not any? turtles with [not stopped? ] [ stop ] ! F( R0 _5 j) V3 `3 Q
ask turtles with [remainder who 5 = 0] [4 D/ _& v/ h2 X4 N7 B9 s
set close-mates (turtles with [self != myself])with[
' b+ E8 q/ t4 Q(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
8 D4 [9 m( Y2 _2 w/ r% kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 3 m& n( X, {; @
and remainder who 5 = 0
% r9 N7 e1 o% p] % Z2 E8 g' K6 j. w
ifelse any? close-mates . d# z S: E4 _" b* J/ M
[
, c! a5 t) ]! k/ U3 _0 W' q4 hset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
2 x0 l w# ~6 Fface closest-one4 g- l" g$ y: g1 [3 z% P% P4 k* S, p
rt 180
( P6 z$ u. _6 s5 v$ A6 r1 Q. i+ Ufd random-float step-size8 T1 z Y$ {5 T* r' b, t
avoid-walls+ L7 m d9 @/ p5 J: J# J) F
set stopped? false]
# c4 U( G) _# V[set stopped? true] ! H$ ?6 ^* u' {* I6 s
] |
|