|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false( K. _% s) ]9 k3 W( K
to go
& \* `9 ^3 x4 g5 Cif not any? turtles with [not stopped? ] [ stop ]
$ o/ Z( u9 t m5 gask turtles with [remainder who 5 = 0] [
/ d7 ?" c/ {+ V% hset close-mates (turtles with [self != myself])with[. M, I& j5 `' o
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 N* ?6 {: G! l8 k; q+ V# e# i' h
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" M1 t" e4 o9 D. x( ]and remainder who 5 = 0
1 T4 a5 w" [' e5 C]
: t1 l+ u; K9 A! \- n) i; K: i/ qifelse any? close-mates
3 r6 H0 x" Z8 U9 t0 G- [+ l[
0 s* X$ ^7 L* t0 A; ?. sset closest-one min-one-of (close-mates with[self != myself] )[distance myself], ^% M0 R* K5 e; s
face closest-one3 {; Q* N& B' ~0 X
rt 180- C; B. @# V: ~! h
fd random-float step-size
7 W$ V% X3 s$ P4 K" a& Eavoid-walls. ?' o% S, A3 H- _8 v
set stopped? false]4 w0 L5 d/ s$ p3 \5 u' k. k. P
[set stopped? true] 1 b& m8 ^/ D* X& a( ]
] |
|