|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ @1 q ?8 n& o7 l. ^* y0 K( X/ rto go4 T0 \$ b; b+ N. D9 t1 `; v2 ]+ U
if not any? turtles with [not stopped? ] [ stop ] / X5 }/ E6 K8 _) G7 }
ask turtles with [remainder who 5 = 0] [( I( ~" D- w1 g! e1 X! }
set close-mates (turtles with [self != myself])with[
1 W/ L) | y2 t3 T(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% w- s. w% n2 h1 l3 Zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& W) C: }% s9 [- l# I ~8 mand remainder who 5 = 0 6 R5 X' y, Z; N: b" U
]
2 x6 c) q0 G' _* }. [ifelse any? close-mates ! z0 T4 w+ o3 j
[
# @0 i1 v8 E M4 a, c E5 `' y) ?set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- W) ^7 i1 @+ G% {' U* h2 T7 N
face closest-one/ Z1 L" S2 t ^
rt 180
5 V. I, L6 q) D' A% ^5 ^fd random-float step-size% x6 \4 X# _& f1 m
avoid-walls) G& \" [) v3 x8 U1 z' _+ \
set stopped? false]
4 Z9 O* H* x$ C5 B- W4 J[set stopped? true] ! S l; P4 l) k$ e
] |
|