|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false/ u/ f8 ?7 V$ q- l" E, ~, ~
to go6 n6 R: P0 x- M
if not any? turtles with [not stopped? ] [ stop ]
1 j$ R0 x2 {; A- d$ ^5 iask turtles with [remainder who 5 = 0] [0 j' Z9 H/ e4 y/ M X9 E, C
set close-mates (turtles with [self != myself])with[
# Q9 x# a+ R% _; T$ L2 o(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
S$ R$ a/ r* Z; N% [and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: b( i9 ~( J+ g9 b, Z; cand remainder who 5 = 0 $ v0 {; S1 w" |- z1 \0 p$ A
]
0 H" x2 M5 Z# z4 R8 |+ v7 X; Xifelse any? close-mates
) i/ }# R* q k- b) m5 H# y[ ) B1 _, s. W% c% W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 }% z9 ]* n" D) j/ fface closest-one
- t" b* Z& f' D8 u qrt 180+ W0 a6 v% M7 J5 {
fd random-float step-size" L& t: s( ]0 w* u- t4 y" A' X
avoid-walls
% }/ Z$ o# G. j7 b$ {0 H& [set stopped? false]7 P/ Z5 R+ S. R% O" `' f
[set stopped? true]
% y0 E+ k8 _, p# v] |
|