|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false; t# e \+ X, ~& c/ F
to go, o( B, ]5 Y* N* R$ f- [- E
if not any? turtles with [not stopped? ] [ stop ]
% e! ?! f+ C8 w; vask turtles with [remainder who 5 = 0] [0 R" q) V3 X# z2 l: c* _) R& L
set close-mates (turtles with [self != myself])with[
/ H$ b! `' w6 G: q2 L8 e$ G5 W(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ; J7 |2 k; G: A, ?+ N( ]( r' E
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 |: D( w- k( G6 j3 V' B
and remainder who 5 = 0
d* \ R- S9 F" G, H$ @]
" I( }8 o, ?- g/ {5 q( h& M0 M8 w5 |ifelse any? close-mates
0 r1 D# [6 F/ j P% k8 w[ 9 i& w( S0 ]* h" d1 G$ T4 }
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ u; J" _5 |% K6 f
face closest-one
- u' o: R" e) u* `8 T/ Zrt 180
1 U! Q- ^3 }: q! |! H& a! `6 Sfd random-float step-size- c& v+ m! n8 ^/ l- o
avoid-walls. ]5 E) e+ y& I, y8 J# g
set stopped? false]& f3 q/ C) a; B! c1 _
[set stopped? true] 0 I. p3 s) s. p- e% L
] |
|