|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
3 _5 t ?$ a* b" Pto go% P+ ]5 _- X& G
if not any? turtles with [not stopped? ] [ stop ]
0 j n% J. z, p7 [5 O3 Z( K& ]ask turtles with [remainder who 5 = 0] [
4 F' K5 v6 R9 E! Sset close-mates (turtles with [self != myself])with[
( X( t6 h/ Z: f(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) h) o( n* V- O0 V) M% C- H
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 1 A: q9 ^, J# j* l" n/ W
and remainder who 5 = 0
9 d4 x( S- G; ?% J] * P- K% ~% f. K3 u3 }, W0 `
ifelse any? close-mates - U0 _, f8 y3 m* r
[
5 A; K# g7 S0 \- ^ @/ \7 pset closest-one min-one-of (close-mates with[self != myself] )[distance myself]9 h* P; F8 I3 [6 ?
face closest-one
2 k) \0 v0 ]7 Y2 I' U. |6 b5 ]rt 180
$ F& s7 q5 y/ ~fd random-float step-size9 t0 P& }( s, | y
avoid-walls
& ^ I, Y* V, R Oset stopped? false]
9 ~! n7 L* i* C0 h1 Z m' Y[set stopped? true]
9 p& l+ U: U4 `/ w6 Q] |
|