|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false) d$ c# Q! s' G: [0 u3 l9 e
to go
" w& S' E& a3 |; [; Yif not any? turtles with [not stopped? ] [ stop ] ' a) K% b- y# u1 \
ask turtles with [remainder who 5 = 0] [/ K3 C0 I+ J# l5 @' w% ?4 f
set close-mates (turtles with [self != myself])with[6 r/ i2 Z7 R3 w. ^1 N
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) r1 X6 g9 X. I( E3 G1 ]7 e, G6 Z8 J
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 1 y3 Z7 h- ^3 p8 B
and remainder who 5 = 0 $ D0 m& k2 [4 q- [5 s6 O3 _$ v
] . Q' v( |5 V, X+ O) s* Z+ v
ifelse any? close-mates 4 Z- }( o7 P3 Y/ r
[ 0 Y) w0 D# ~* Q# O3 B
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
! K. _" v2 V- q X$ @- Tface closest-one; I5 O2 u7 c% w* Q
rt 180! U9 F# \% d* o' U& o! ?
fd random-float step-size
: b/ H1 {' @# s& W: ~. Vavoid-walls+ v, u9 Z+ [+ Y9 B% E6 c9 D
set stopped? false]! \/ S/ O0 f6 m& Z3 l+ Q; Y( }- {
[set stopped? true] ) x7 m4 {0 H1 f. W' v& b: Q6 A- o3 M
] |
|