|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false0 f- T/ ?3 W5 R. y, F
to go0 l; q, f# P- [5 N7 } Q+ Y
if not any? turtles with [not stopped? ] [ stop ]
: t) G& P( z# |$ Q I8 l. G. G0 Qask turtles with [remainder who 5 = 0] [; G7 R# c: J) R1 P& x: U
set close-mates (turtles with [self != myself])with[) P) J# K. B! M# x8 n( Z; ]
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) * @3 c% i( }( P. G1 I# e; z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " m( i! j7 Z) P K2 \- D x& v
and remainder who 5 = 0
& y: ^+ Z4 e! t( U/ E+ [& d& O2 q9 R]
& G6 b1 E8 i5 e, c* q% oifelse any? close-mates
- }% c; s" r; O- m3 W1 Z; i[
6 o @. {; T$ R7 {( X- dset closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ r. C* w6 j( n9 T
face closest-one
8 |- a, j) o9 u$ i5 b$ h2 f5 p# o3 hrt 180% W& l; j6 c9 z4 g5 ^
fd random-float step-size+ B4 `- t) o& Y: o) o6 {7 N, |$ ]
avoid-walls
h/ v" t! Y1 Q8 Mset stopped? false]
) b8 F' T( H5 ?% x- ~* G5 N6 ][set stopped? true] . Z7 {- B# A4 T* i, s& l" P
] |
|