|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
; E& m8 S4 m r- U! \to go# o/ E: S$ `( W- `# b: ?6 u
if not any? turtles with [not stopped? ] [ stop ] 6 k3 m1 Z' ^2 p4 Z3 t v+ @2 p/ e( J
ask turtles with [remainder who 5 = 0] [
: I" Z$ f( x5 ?3 Mset close-mates (turtles with [self != myself])with[
6 H3 h7 E5 ^. [6 e(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
~ m" z. _ {( ~6 U/ \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
4 ~/ Z: l4 y) ^% C# I. |and remainder who 5 = 0
, c: E7 J, y, A9 D] ( r7 w! c o% U* x- A
ifelse any? close-mates % o3 p/ W+ e5 ~/ w# }0 O
[ 2 y, J: h. o% \0 ^0 {3 r: t
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]7 E+ I1 }* a5 J) w- `! H; r
face closest-one
" H2 ?: p2 }3 i, L# t, art 1803 w6 l/ l2 m* @% |/ g- k) g2 |
fd random-float step-size
+ Q4 h. B9 R9 H; {9 xavoid-walls
2 m6 ~2 |* Z- ]9 f( n9 Fset stopped? false]
! E/ R+ Y, B, e2 p, a! O4 V[set stopped? true]
J* }& P! G7 H/ Z/ o] |
|