|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: N, o* _8 W0 l; l3 W6 Oto go
/ a% s1 Y+ `4 U( F7 o T* _if not any? turtles with [not stopped? ] [ stop ] ( F( j8 f% Z; x+ j! J% v0 J
ask turtles with [remainder who 5 = 0] [
1 E9 K# b0 |3 X1 B1 B j5 xset close-mates (turtles with [self != myself])with[2 c0 n# h- r8 D0 v& M; ]
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 d2 L# B0 h/ O0 r$ f6 `8 Y9 A w9 Fand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& X3 U- |0 j2 w" S) t6 L! R# [and remainder who 5 = 0 & d. D, C- p3 ^7 \2 ^; i0 S3 R
]
1 P* |* R- f" c4 Y* e' Wifelse any? close-mates
' O! e5 ~& e% H r0 N[
# b4 h$ z+ ^) L0 O2 D& @8 }set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 ?% ~, w( p) `6 Y. N$ Pface closest-one
8 ~* f; R9 N1 A( v; p2 g1 Lrt 1805 k4 ^3 `; F8 a* M& r% ~
fd random-float step-size' |! o# S( w2 G. d3 M
avoid-walls
& C! \, W+ h$ x2 Q9 t1 V; Q' xset stopped? false] y# R/ ~' W+ R0 Z. D
[set stopped? true] ! C3 y% y' F2 k0 K0 \% H0 ~
] |
|