|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, [3 H1 w# i" u: uto go$ E" A3 S0 K; h, S
if not any? turtles with [not stopped? ] [ stop ]
; e* h! R3 h, Wask turtles with [remainder who 5 = 0] [
% t# R u" S: M; G6 Y! J+ Wset close-mates (turtles with [self != myself])with[
: ?2 l9 O: y, ~* P(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) u4 M+ d4 r+ }and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 3 J" [, l* ?9 t( |% A6 l1 C
and remainder who 5 = 0
: N& p* B# j$ B, o6 X8 P; g0 S] ' K; s# h- P: z B8 i
ifelse any? close-mates - k6 x* H4 w2 k( N4 ~
[
) i# g+ g8 J3 V7 H7 {$ _* N& Cset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 v0 C- Y/ U. P! V) e1 i+ dface closest-one
+ _* ?! ~* X0 {& b6 W: {# D3 Hrt 180
- _0 `5 X8 T5 b4 ~8 b& I6 Pfd random-float step-size; N% ~. C/ W- j) o: A8 z3 I
avoid-walls
( S% z' c9 P7 C1 u5 O* cset stopped? false]
1 G- x9 o( U* v( a[set stopped? true] # W" L! n: t, x! o0 S
] |
|