|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 n- }1 g7 b, A, i# S% V; Y& `
to go
; B3 c0 ~' l- M: {6 s' @" h5 {if not any? turtles with [not stopped? ] [ stop ] : i e( k$ r. z* L+ _" p
ask turtles with [remainder who 5 = 0] [
) Q: S$ s6 v3 V }: V2 W. Pset close-mates (turtles with [self != myself])with[
" Z; _" @: e8 X( [3 r% c1 G(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 d, `# W2 i$ d# X, ~1 \
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 x Q% J' C# m0 E/ `
and remainder who 5 = 0
" L( ?5 L! T, O8 K) g]
2 c7 v; G; y; m0 c Difelse any? close-mates
. T' j( U4 \% z[
9 c5 P# j6 l; U! }% qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]% H' D' w( U: z; b' S" o- c
face closest-one, i5 V: F6 _; q8 X( m/ T/ c( x. g
rt 180
5 ?; r' X" X) |; v: _9 Qfd random-float step-size
0 t( Y- L3 Y7 p" ~! L( d, B, Kavoid-walls
1 e; V# M0 s" k$ @0 fset stopped? false]. v: x I, ?% \, @; Z7 l
[set stopped? true]
1 Z, X( J0 D" `. y8 n, \- w# g) C3 ^] |
|