|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& T2 Z" s" ~( x- W" G8 U! i3 xto go) _9 s% G9 f" O, l) \: Z _. Y
if not any? turtles with [not stopped? ] [ stop ] * D* v4 D- J2 L" }. t" ?9 Y2 ~% l
ask turtles with [remainder who 5 = 0] [! G: }1 E1 A" z; L
set close-mates (turtles with [self != myself])with[' Y" i. L- m" x
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 K+ U* S" [. i) o! F6 f+ w
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& j" f. A9 z+ o' i6 {. Oand remainder who 5 = 0
8 f8 c% Y# H9 @ M0 x] 5 b& p4 v2 E: R0 {- {
ifelse any? close-mates , ^! s! Q- \% j
[ ; B* q0 r+ b C5 g w7 t5 ^
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]0 K/ b7 F. A1 f5 Z q
face closest-one
+ v& l% g0 U" l" t: u6 h; srt 180
3 ^- K0 ?4 V R4 \3 I* kfd random-float step-size F3 d+ [$ L8 x/ p
avoid-walls
. v! v' j: |$ u. Iset stopped? false]
( V" _" `% T9 ^! [; V( \[set stopped? true]
9 k. [, U. v |9 M. X] |
|