|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false! D# z8 G2 [$ M1 Q l! @
to go
8 d% F; J2 e8 l% Z3 ]( ^3 Bif not any? turtles with [not stopped? ] [ stop ] & S: N0 t: f, T6 g) _, {7 L
ask turtles with [remainder who 5 = 0] [/ T2 z4 P S2 h: v3 i
set close-mates (turtles with [self != myself])with[$ j6 r9 K$ r- f3 ~# @" y- P
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 Q9 H. I) i- j$ N U; t9 D4 iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( q/ ]4 t& T* @% `5 uand remainder who 5 = 0 # d( ^& ~; A, E9 j8 n5 R
] . D, D" g+ J, t' M `4 K0 ^" \
ifelse any? close-mates
: { a. B* c: A. K- Q2 x+ q[ 3 g a( k; W% B* r) w
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* S2 f) k+ w6 F" H+ m2 U3 p5 bface closest-one/ |0 F3 G. ^; n/ u
rt 1803 p! x2 x+ B: h1 W( \
fd random-float step-size, U$ y& m. T: ] \$ @, n
avoid-walls+ q+ l, d6 t$ o, r1 ~) w
set stopped? false]
) T0 z" Y" [2 S[set stopped? true]
$ ?$ C" f- |2 m7 L, ?) G, _ A] |
|