|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 K! X7 s$ ^% X8 T' n8 ato go* m% F0 |, \7 e* b( d7 G. T
if not any? turtles with [not stopped? ] [ stop ]
5 Y+ R$ d: _' S4 m |ask turtles with [remainder who 5 = 0] [
( r% j( Q( [6 z) s$ i4 P jset close-mates (turtles with [self != myself])with[. }; H( F0 B8 g% Z: N: v5 x# k7 K; v1 z
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) $ `; d5 c' l+ C7 b' f! Y
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 d5 ~" b6 N, v1 b* N2 f& aand remainder who 5 = 0 " @1 H/ L& o M4 s. w2 X; a4 H
] + e3 Q- K- r6 m9 W7 m/ W' t4 b! T" J# k
ifelse any? close-mates
# U+ [; r/ o4 r3 W9 Q[ 5 h% l" h+ ~. l( e7 }3 k" {6 D
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- K s7 V4 B |4 Y! j+ C# h
face closest-one! H- q' B& U* h# z" D& n7 K. t
rt 180) n1 ^# N& g" m* B( p% {
fd random-float step-size/ D5 L, z' a- F* v% M
avoid-walls* q8 X* ~4 i. J4 Q
set stopped? false]. ?' v9 Z8 i2 T6 W
[set stopped? true] 2 i/ g$ L# Y# t7 E- U
] |
|