|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ i$ V' a- x5 B7 Q) ito go
, M! z) A- c7 X2 \if not any? turtles with [not stopped? ] [ stop ]
! p+ @- F1 ~1 A4 p2 ~& A. O, fask turtles with [remainder who 5 = 0] [9 q4 |4 y8 |. X, o& B
set close-mates (turtles with [self != myself])with[: ^( r& d* g# _2 w
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 m: j/ h# e- q: r H8 X# ]
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( f6 p# g8 w6 v+ {- @9 gand remainder who 5 = 0 + u O6 t4 z4 C; G* o9 Z
]
# |0 Z0 @$ H/ kifelse any? close-mates
; o- _6 P" O% o! c$ W* `1 ?7 z' ]7 n[ ! {! U" v& x- e. q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]% n% @6 ^: ~7 s! \
face closest-one4 q1 ~# s0 X# V
rt 180+ @% P4 |: i0 R
fd random-float step-size5 a0 }. \1 _6 B! Q a1 I# \
avoid-walls
! `0 b8 M$ [7 Y+ k1 t0 sset stopped? false]
2 M+ X) l" M; n' T* E[set stopped? true]
6 r) V" E& _7 p0 U# o* S] |
|