|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false2 Y1 S, I5 S+ W4 a
to go
# L; W J* ] ^7 M: G, c( ?if not any? turtles with [not stopped? ] [ stop ] 9 _, a6 s( Y$ T6 b. b9 L4 x: R
ask turtles with [remainder who 5 = 0] [5 p2 C5 y1 R! S) p1 _: d
set close-mates (turtles with [self != myself])with[# k" h4 p7 F- g0 Z/ l
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( O7 W7 {" \7 ?* p9 S+ ~/ X
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
, ^2 G% P5 S- u; H1 Sand remainder who 5 = 0
/ o. a7 C' B* M: [- |]
' |+ v; s! x% x+ n% y3 ]ifelse any? close-mates 9 q& h; r1 z/ s s$ w( d; S
[ : q, g }$ _- S2 _
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 P0 h( |& t0 q8 V) l9 q! z9 x
face closest-one
& d: t1 O* Y# J8 T% Irt 1802 p9 }, _! X& i5 @8 j1 J1 {
fd random-float step-size) d C9 Z* ?1 W; W; }$ Z$ J
avoid-walls8 c1 K" v/ b5 F& R/ x
set stopped? false]. z: M. V2 F9 Q# J& Q& E9 W4 N
[set stopped? true]
! h2 W& \5 ]) U: |] |
|