|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
b3 ~ O4 y& B7 j' o/ P8 ^; qto go. @- C3 H: o* [$ E! Z$ n
if not any? turtles with [not stopped? ] [ stop ] % V) d: R: P, D
ask turtles with [remainder who 5 = 0] [
5 o: Q# P8 s5 v2 wset close-mates (turtles with [self != myself])with[
0 T# l% z6 a* E$ H(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 o7 x# P$ m4 Y' z2 F; Band (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 I1 n2 R0 ^! p, @1 \. V3 K: rand remainder who 5 = 0 - b' W5 p5 b) X" {
]
6 s- K! z1 ^; N/ g2 G, L9 F! K2 difelse any? close-mates
4 z; u! d: }! P) R7 Y4 r[ . s9 r9 ^; `8 j9 m! |9 R& x* _! W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# T* U: `4 H- G( h! wface closest-one
7 x+ W" A; [7 Hrt 180+ k V7 X' W: E( {$ R5 {
fd random-float step-size- |3 w9 b& Y# I7 b% | i. U$ N
avoid-walls
7 j: n* Z$ b5 S1 Xset stopped? false]+ {4 A0 O3 u. ~+ u7 z$ F
[set stopped? true] " |1 \$ n2 e% j
] |
|