|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false/ h! Y3 i0 Z/ }8 d
to go* F, G# U7 j( Z6 {
if not any? turtles with [not stopped? ] [ stop ]
* ~' y' r' ^: g4 l* Z$ ?ask turtles with [remainder who 5 = 0] [$ R, A5 X! Q3 Y% w! }
set close-mates (turtles with [self != myself])with[
# r6 D. \; m# i) w& z- z- g" E$ }(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - e1 y% |8 E4 y0 s/ }: U
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& Y# l7 T9 b1 h% `( ~and remainder who 5 = 0 9 l1 `! ^, ]4 P" }- ]
] 2 [7 K2 s1 f( r/ }
ifelse any? close-mates * @/ q$ K( d+ i0 R$ P9 t
[ 8 C# w- V% @& b/ I0 K) m
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' R' K% @4 m+ F: p2 Lface closest-one
' Q; F3 X' T. ort 180
; w/ v, [6 ?0 _" Kfd random-float step-size A- Y" Q5 l k/ ~( `
avoid-walls
9 y+ b7 M' P7 x0 v! rset stopped? false]; G. z v6 @4 H5 j# L- f
[set stopped? true]
% k$ \ F; C% L& G] |
|