|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- ^- Z; _* T9 l/ g" Q7 F' v* s ?to go5 `+ ]- N8 Z* k' q
if not any? turtles with [not stopped? ] [ stop ]
1 _, {. S2 u4 o5 Vask turtles with [remainder who 5 = 0] [
1 O, q. U: M6 F1 M9 ^6 t& ?set close-mates (turtles with [self != myself])with[9 D8 I2 E9 A/ j
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : S! ]. y5 `& _7 _$ g/ u& _
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ) b0 L' J; D) W$ B0 }$ `$ g
and remainder who 5 = 0
- C" {4 C, p3 u4 V/ |5 o8 N0 `8 M] , Y# f9 D& L. |$ @ B+ w. l
ifelse any? close-mates
) G3 N: B+ i ^! W* o: C[
* d& m- y: x$ D: Mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* k$ O. ^' G, M7 `face closest-one
9 u/ B. _4 l2 S) C* Trt 180
. a5 L# b1 E V* C7 P4 j1 xfd random-float step-size
- l$ \7 J$ S& x/ Z$ @3 C$ Pavoid-walls, w: j4 ^' j* {- ? v+ j/ ~
set stopped? false]2 D8 B @: F) v$ h, P# Z
[set stopped? true] & T8 i: l6 g/ ]3 D8 ^
] |
|