|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# Q# m, u |. l% T* Cto go
9 B, z. r' D0 t0 b4 Hif not any? turtles with [not stopped? ] [ stop ]
7 U& R; P( Q/ a6 B3 dask turtles with [remainder who 5 = 0] [) O' Z9 A) R8 [7 @" N
set close-mates (turtles with [self != myself])with[
& j& y0 F: `% Z1 q(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 8 `' G/ ^7 G+ Q$ z6 T
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
0 S/ L2 S( {: |% u- t- g3 T/ Yand remainder who 5 = 0 3 ~6 [* j* n6 C* F5 m
]
9 A1 C) r: u" p* f' k- K/ Rifelse any? close-mates
3 D$ Q/ Y' X5 b7 r& E[ / O, Y4 p d7 x, U& b6 J
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' C$ z/ D3 o1 }: ?( H& oface closest-one
0 u: S6 k$ [, F( u8 K9 D! t Jrt 1807 w" n" t$ c4 @: m& t
fd random-float step-size
, v' R8 D! y2 ~( W7 P& E7 lavoid-walls
: `& e0 A; n* p7 pset stopped? false]
5 s: p& I. B, Q[set stopped? true] * w+ k& Z: L+ W+ m% Z
] |
|