|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false9 T' y- H0 [. C4 K
to go
J& ?+ |6 p+ }1 Y8 Nif not any? turtles with [not stopped? ] [ stop ]
! D+ F# r6 i- a& Pask turtles with [remainder who 5 = 0] [
# r7 B8 n: [4 `( o( n/ e( I7 o `set close-mates (turtles with [self != myself])with[
0 P/ ~ z6 Z+ [1 ~- N4 S9 c1 O(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / W9 T) z, p3 P7 s; [
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ |9 Z i- Z6 ?% l& u. q0 V* d3 ?; M! F$ ~
and remainder who 5 = 0
4 U/ N4 M6 L; K, \] 8 \" m9 S% j7 L( J& X1 `( b3 l2 ^+ X
ifelse any? close-mates
: U& v w. P1 D9 R[
) g: C9 H5 ? ^/ J) m3 eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# d0 N5 u' q6 }" K& I+ q! I/ ?face closest-one
" ^; y; l8 e l: U" s, i2 irt 180
) O7 J# H: ~! ?, n% y0 s& Wfd random-float step-size
/ E9 f/ R' [) Davoid-walls2 k+ j8 B- O/ ?8 s# i
set stopped? false]: H/ o/ g- a' ^# ~
[set stopped? true] - o- H5 l9 w: G9 [) v' h
] |
|