|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: f$ e6 t+ q4 h3 u2 R8 A: Uto go" y3 A. q7 N0 n3 Y5 d- {
if not any? turtles with [not stopped? ] [ stop ]
, N& [5 W- D, i M- Nask turtles with [remainder who 5 = 0] [
! T% W+ U }5 `* Uset close-mates (turtles with [self != myself])with[( ?: J- c/ [9 z3 x" B
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ; p4 u( }2 Q* U" K: V
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
- z/ O( V9 q/ f2 E3 R+ l7 v8 tand remainder who 5 = 0 * M7 O) e: L! B; ~* {6 A. _" u2 v
] . S1 V5 N* C% x5 r
ifelse any? close-mates " J% _ O! R1 ?( W
[
9 E7 M) ?6 F P6 _. u- l: n( k+ Bset closest-one min-one-of (close-mates with[self != myself] )[distance myself]& K0 ?* e" ~; {: S$ L" s8 A# L" q
face closest-one* u) x+ n: X; E( F# P0 @4 z" I
rt 1807 l) @+ d( E, k9 ^& L5 s& f
fd random-float step-size
2 v, _, a) u M |/ j( M% e; w( o7 Favoid-walls
0 ~$ @2 B8 K3 u# uset stopped? false]
, A1 }7 y' ~2 n3 C6 L" T[set stopped? true] ! w! X* |$ ?2 p9 @ w
] |
|