|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) |1 T# `0 K! Y1 }7 Eto go: w/ l6 y$ o# z0 `6 A$ a# d
if not any? turtles with [not stopped? ] [ stop ]
) m& D: T" d. g/ bask turtles with [remainder who 5 = 0] [+ u4 G; {* V4 A( \; \
set close-mates (turtles with [self != myself])with[
6 y9 b' a6 ~& j( L+ ` F& E. |(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
q8 T o9 }# q. b7 A0 Aand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) a4 G+ S$ ~; q4 c
and remainder who 5 = 0
& S8 D+ f" r9 | }1 T( A+ }] , I$ a$ a6 ~5 V4 z& n5 K2 _8 P
ifelse any? close-mates 2 \! M* j9 n, i; x1 H
[ 3 E& t% _& P5 Q) ?& V5 E
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]9 ^. \; M% T; j
face closest-one' W7 Q: I% o! J
rt 180
! ]" b; j3 O& N1 `fd random-float step-size
: b/ C$ `: B8 U! m& kavoid-walls
/ o7 S) W* ^" g3 b! i& xset stopped? false]- n2 S* D+ I3 s
[set stopped? true]
! X8 _, @" c, [0 G8 y] |
|