|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 k; d; Z4 J# K" B1 ~/ j( Xto go& m' _7 [- |$ O% ^0 v
if not any? turtles with [not stopped? ] [ stop ] . f2 |0 J7 n" e+ J4 K3 K6 d
ask turtles with [remainder who 5 = 0] [# _, a( ^/ E) F/ `
set close-mates (turtles with [self != myself])with[ |& H! h0 \% Z; f
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
3 N) B, ?+ j7 M: Pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: l3 O, s4 L) M# |# Yand remainder who 5 = 0
( n0 u$ d3 j$ c6 w3 G3 L]
, O5 \& f) V/ ^1 Zifelse any? close-mates + L7 s& h4 I+ U8 F
[
) q9 K& K8 B$ O( t& I" Fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
- W2 |0 D3 w# Z L6 Uface closest-one3 t8 a% u' J) C+ I+ j0 z' O
rt 180
, _8 z2 u$ m/ E5 L3 E+ |fd random-float step-size% W6 P8 m+ ~2 r7 T8 F
avoid-walls. S! ^$ [- ~& j- }
set stopped? false]$ z/ ^5 T$ i2 t$ ?
[set stopped? true] 1 y/ {% P2 H" }4 `, k; m: _" h
] |
|