|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 j8 ]* e5 J8 L9 d- I
to go
# q# A: n- l6 w6 h% |" {if not any? turtles with [not stopped? ] [ stop ]
3 H0 Z( s9 x& @1 q. Gask turtles with [remainder who 5 = 0] [
5 n1 ~0 ]7 L$ C6 i* Z) uset close-mates (turtles with [self != myself])with[
! W4 z! f. v4 ](abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / R7 v( O" [4 x
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ U6 n; R* l9 V! j
and remainder who 5 = 0
- r' N5 _/ Z. f1 n- J6 r] 0 ]. I& j; g% C5 @+ b
ifelse any? close-mates
# C0 R; V' p3 U4 V[ : k' @% S9 l) H# K+ q4 K
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]3 P I {2 x" ~; ^- I& F
face closest-one% c. [- `% z, S, x
rt 180
+ d) y, v1 E: K0 h4 p0 o* ]( `fd random-float step-size3 V8 v( W# \1 L: p, t
avoid-walls
' I- ?: \7 Z: ]6 x& yset stopped? false]+ ^* o l0 X4 q0 K- A
[set stopped? true]
2 p: W4 F8 P! s( n3 L] |
|