|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false, x1 I$ H6 C+ ^
to go
; s9 J+ C% X( d3 Iif not any? turtles with [not stopped? ] [ stop ] $ H, `/ b @! M: \% j3 l3 Y0 c2 J
ask turtles with [remainder who 5 = 0] [; J$ S1 X8 \5 j7 A3 ~/ d" `: Q) ?9 a
set close-mates (turtles with [self != myself])with[
; E& x/ d) u4 {# ~5 h" f* D: L% x, P(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
! {" ^2 u1 m2 s% r+ f) o' L8 wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / L2 t. o: H( P+ h# P
and remainder who 5 = 0
* h# |" _# a3 Y& X] 6 p" G. @! p2 a0 x, \. B3 n7 J
ifelse any? close-mates 9 f8 h& W. l- ?( H% R
[
6 q' b' {: |- P, g7 M( T5 ~1 Cset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. `% ?4 P, p4 w& r4 I
face closest-one; ?" K j% _* L
rt 180
$ D3 X% c N3 sfd random-float step-size3 p, l7 ?. s! e4 ~
avoid-walls5 X" v5 F- u1 B7 p
set stopped? false]; E$ E3 l5 g* h, @
[set stopped? true]
$ M: F6 w6 V( }& U, P( t] |
|