|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: d3 @! F& M1 s" _# ^. J/ x f, a; Fto go
; N+ j& n# @- T, E+ Fif not any? turtles with [not stopped? ] [ stop ]
" P& G) ?7 U0 {1 M' v) B- eask turtles with [remainder who 5 = 0] [+ m7 y! o- c/ Q0 s" N. T
set close-mates (turtles with [self != myself])with[
0 \' n/ p+ n( O$ E9 V(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ Z' u ?* e6 i K0 [6 Tand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 6 b$ t: v# J* L% C& O
and remainder who 5 = 0
y) h% o- {! j3 O] 7 {6 p* ~* g1 m4 d- c t
ifelse any? close-mates 6 }0 B4 z7 k. {9 A( ^: [' g& L
[
# z" f5 t3 u2 B5 _; l. c" Dset closest-one min-one-of (close-mates with[self != myself] )[distance myself]! y& @/ {! j1 L2 ^5 c
face closest-one
4 `3 E$ y4 X% {, Zrt 180
- k- @" y0 S0 D" ofd random-float step-size9 N# P! w8 f t% |6 Q! D' x' S
avoid-walls
7 m$ C, L" ^2 N6 o4 T# Nset stopped? false]
2 O* _4 `- a- ~ z: i& e[set stopped? true] # O; O- K! g+ X, T1 Q1 ^& }
] |
|