|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" m( w) k3 S$ q1 Y) A
to go
# o& h/ g2 {1 O; W" K2 e3 I* aif not any? turtles with [not stopped? ] [ stop ]
~0 P* q% w% r2 j5 E6 I" S0 vask turtles with [remainder who 5 = 0] [
* F$ f- U5 h# O# h# Fset close-mates (turtles with [self != myself])with[' Y' n* Q+ q4 u6 @7 a$ q3 ^5 ?
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
6 }& ]* V8 d% h2 f3 m, f8 |' M" k8 Land (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - D M% G) d, P5 u$ ` L
and remainder who 5 = 0 9 q$ ~0 H& E1 i0 G. _0 `
]
& D; A8 B1 a! F) E4 _& F7 N; p- uifelse any? close-mates $ I \" v/ h. M7 _% F
[
& }! H% E; I* Z# m4 `1 R# Qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 `$ |' b1 n0 L" V" Bface closest-one: p% F" u. P( {
rt 180' y1 T i) _- t
fd random-float step-size7 }7 c, ]6 l. S
avoid-walls9 N M0 B5 Q- K1 r
set stopped? false]
$ U4 L) _, g! t! Q' b- i1 W[set stopped? true]
( ~* v/ S! a# o; Q( h$ H] |
|