|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- W+ n" ^5 @( f. J! O5 jto go6 Z6 L, D" I8 j
if not any? turtles with [not stopped? ] [ stop ]
( V' V( y4 C ^* f/ rask turtles with [remainder who 5 = 0] [
0 g6 X9 S$ e/ J5 Bset close-mates (turtles with [self != myself])with[
+ Q9 M2 G# m7 m7 H(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( T/ e( K/ _" e8 P
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" @; l& K2 u) Y3 _5 Gand remainder who 5 = 0 & V% F8 p* W. d$ {1 u- Q/ b
] - @* }4 O* L1 |& L O
ifelse any? close-mates 0 [5 v8 D1 v U
[ . B3 q* y; B O. ?7 e/ Q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
H3 I1 S e5 A2 sface closest-one
+ I, z: q: @4 i& jrt 180
+ \9 V9 b! d& s* b/ y7 Sfd random-float step-size
1 e' E, m2 }$ x5 _0 C/ Zavoid-walls8 B D, P) m0 s4 @, G' S3 ]
set stopped? false]
$ w# i. I5 K6 o0 c[set stopped? true]
4 r# P' t# c4 y: q2 ]] |
|