|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false7 x ^& w0 E( w4 |) b0 e; g
to go
7 q9 j; B# s: w0 c# s: v0 Nif not any? turtles with [not stopped? ] [ stop ]
6 v3 K$ ^1 K! a$ ~3 |' Yask turtles with [remainder who 5 = 0] [
9 J. x3 B7 R& h) I( [* `set close-mates (turtles with [self != myself])with[3 m. ^0 \6 B6 k5 @% _" Y( k' p/ E
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
o# r |: Q9 u4 I' @; x! j! pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - n& M9 L4 N6 `0 M- a1 j( ^
and remainder who 5 = 0
# A/ G9 } e* q" s! D] 9 s5 S4 {' }! n1 u. m2 L
ifelse any? close-mates
\( \9 o% K0 t8 D8 _[
- i/ z$ k& i7 y4 P4 z+ o5 W( u! qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]1 g" I7 p0 Q, B$ C7 R5 u x9 H# h
face closest-one# H2 W0 G g9 s4 ~- L
rt 180
& ~, P Y! A9 V. A# mfd random-float step-size0 |% Y$ S+ e% S& u7 ?2 \8 p% n
avoid-walls$ J) M, a& c! b* n6 w; m& T
set stopped? false]
- M$ P5 i# M+ Q2 z6 |$ z0 W[set stopped? true]
9 S U1 i5 p% k5 S& f% H1 E7 u# B] |
|