|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ H# p2 g# `' e+ _0 N( W' z9 mto go/ X: s) z6 R9 r' |6 [" r
if not any? turtles with [not stopped? ] [ stop ] ) I- n" N, @ F! v) |5 K. }
ask turtles with [remainder who 5 = 0] [
' E+ t+ ~4 h7 xset close-mates (turtles with [self != myself])with[1 B" c1 {1 w. x, d
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 Z3 Y, K% r' J; k
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ B5 a- ]& ?1 A, j3 K, ^* E, rand remainder who 5 = 0
( B" b8 W. O. {5 \6 o2 E] - m* v) `) Y, X+ e
ifelse any? close-mates
2 F8 u7 P' d/ [* D6 L: h. t/ S[
- M7 |0 x7 |- Kset closest-one min-one-of (close-mates with[self != myself] )[distance myself]( D: a/ D8 ^: n& H$ P" q( M) ^: }
face closest-one; K# Y+ ?6 g( r; \& |
rt 180
4 L. N# M7 |. w0 [& _fd random-float step-size) X6 |1 x, Y; q* i
avoid-walls
$ _# q, B- R6 K5 ~5 j, Xset stopped? false]
' j" E3 u) n. k3 V+ x2 P[set stopped? true] 4 z0 M& ?; f9 N' |2 ~ ~9 F) s
] |
|