|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ ]7 M8 q+ d. v. _* E( Z
to go. u, W# P7 n9 L- b( h
if not any? turtles with [not stopped? ] [ stop ] - ?2 \7 H y: L9 F
ask turtles with [remainder who 5 = 0] [
& i+ Q4 ?0 X8 K0 D, B6 K( Rset close-mates (turtles with [self != myself])with[0 n8 ^' }! u* ^" v* ^ V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
3 ]1 {8 A6 [- r+ \, o+ W% q* iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , R: b7 ]. `/ g, a. N, x
and remainder who 5 = 0 ; e6 A- U% e3 e
]
+ ~/ J. X2 R z' i6 ~# x$ \% D$ a0 Pifelse any? close-mates
- u- e0 Q7 ?- A7 |( |[ 3 d9 ~9 ]1 F8 T! x
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]; k+ y9 ?4 ]& b0 g
face closest-one
6 {; Q, C* V3 C3 brt 1808 T& h5 `3 {5 u. u7 R- H6 \, e: Q5 R
fd random-float step-size0 G5 q% O2 ] K* N: e& v0 B
avoid-walls
) B' z5 E, L+ U! mset stopped? false]
- i9 R# h) _9 m" g- u- Y8 G2 A[set stopped? true]
$ B% R) R9 M a6 T5 Z$ r3 `] |
|