|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ e: q& m# o1 `; {% Q* d+ n
to go
5 \/ i$ D" M4 ?3 X4 Zif not any? turtles with [not stopped? ] [ stop ]
. H: _4 Q, _* M3 J1 cask turtles with [remainder who 5 = 0] [! }1 I6 i" o- P5 B8 d
set close-mates (turtles with [self != myself])with[. L% o6 i7 p6 s: f. J* j% T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
7 p' O0 m! W: [3 R9 r! gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ H' I+ J- v* g# B! Dand remainder who 5 = 0 5 X: C0 d" y/ N6 t
] % h2 _3 t0 ~9 H) O3 M* x# [
ifelse any? close-mates
* {1 d; c0 a% Q% `+ R[
9 H, N8 r! G# ?' Qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ @6 p6 v9 i: b; h* b
face closest-one* s% q& z% [+ z
rt 180
' d8 d8 N4 ^8 nfd random-float step-size, T/ q8 @* U; n" o
avoid-walls% r$ g2 D: z* L
set stopped? false]: x: f2 ^7 Q9 x! b* e
[set stopped? true]
# m7 ?' z$ \8 L! }1 }* K] |
|