|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 O y7 S, R& M! P$ nto go
a3 n! F; x% K" Y* nif not any? turtles with [not stopped? ] [ stop ] # {- i: z/ }6 Z( ?: t5 v
ask turtles with [remainder who 5 = 0] [
/ I$ T8 e* _4 O( M9 P s. Bset close-mates (turtles with [self != myself])with[
" I2 f& j8 }, E; t' C) t(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# e0 p1 q7 X" ?9 Dand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
5 i' H2 G4 E( F. aand remainder who 5 = 0
0 [9 {7 S4 Z \) r8 j9 p9 K- h* m]
% E$ c, f% ~4 U$ I& ?% vifelse any? close-mates ( A. ~" \5 c) ^; p4 W% O. [
[ % R, `" n+ Y$ T% D; L5 W; ?: ^4 k7 H
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]2 ?! [; N. s* ?
face closest-one
+ Q. M i7 M. X2 Y8 O( ^rt 180& }! p" C, r$ p$ X# b0 O; {
fd random-float step-size
- I/ f2 l2 U K) w& |# \5 p! L) Tavoid-walls
5 y9 i Z& o9 H, dset stopped? false]
/ z) d/ w# ]/ v- M6 }) p[set stopped? true] % n4 U8 Y) @( ?( [# q
] |
|