|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 N; p+ T/ `0 A- e7 v
to go& S f: ]: w$ m1 ~
if not any? turtles with [not stopped? ] [ stop ] / C& c) Y( S, m$ f- t
ask turtles with [remainder who 5 = 0] [8 ?+ X$ A$ }. ]
set close-mates (turtles with [self != myself])with[
2 `5 \' x. a! F( M$ \! ?(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ! c- n+ Q h. x) ]; k: J
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ' b9 A; I( b* s$ |0 [1 f, I- g
and remainder who 5 = 0
% t/ o% F; l: d/ K! w7 Y] & P# W0 Z" m# D5 l8 m+ z
ifelse any? close-mates + `( }8 i8 l1 _* H L
[
0 H+ |9 v8 {1 R. J2 d& |$ |set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
k8 Q8 H4 O5 q6 tface closest-one
' r) B' g/ F" }2 z+ }rt 1800 r* o* {0 c, @
fd random-float step-size
# c5 I# T1 H2 ?/ w0 }3 T# N* mavoid-walls
2 ~2 x3 @* p4 H. W& L! yset stopped? false]
. r6 l4 b1 a& J0 B[set stopped? true] % D2 R5 h p0 s/ n- a" \! ~
] |
|