|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 j* X" l% R9 c; n9 h- oto go) |0 S. s& _9 _6 @+ A
if not any? turtles with [not stopped? ] [ stop ] $ e* x- c. ?/ [ P0 c5 S c9 d
ask turtles with [remainder who 5 = 0] [! V3 U6 n) w2 |0 H- `
set close-mates (turtles with [self != myself])with[. J- Q# p p1 v# S
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
6 |6 {4 Y; l1 q K- o7 q: ]5 \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . f, u/ G' |' o2 Y
and remainder who 5 = 0 & ?( ^, d; Z+ {, h
] + o7 b) K$ |( W, T0 A
ifelse any? close-mates # {0 C7 n3 R* L% N. T) ] p
[ . j0 m3 s1 A1 c. Z
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
" v& A* g2 x( ~; Yface closest-one
8 l# Q. _. @) `. b* b" S/ Hrt 180
% i- {7 H9 Z3 b v1 _+ Wfd random-float step-size$ S7 X/ G, M6 `/ y$ v
avoid-walls
" J; z0 n7 X. J" f0 xset stopped? false]
6 s9 F& o P% \[set stopped? true] 1 _& e! G" c1 p) L* |- A( S
] |
|