|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false) o/ o, o+ [* p, V# `
to go' l- k' G% i3 m
if not any? turtles with [not stopped? ] [ stop ]
) p! b1 x) s, t$ X! m2 e9 w7 wask turtles with [remainder who 5 = 0] [
+ y; y, P/ W- w4 }- Y) aset close-mates (turtles with [self != myself])with[7 c! z% E# o9 M
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; S; Z8 O D, e3 a- M% u# |5 d0 iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
3 ~. C1 L5 S0 S# q% E% aand remainder who 5 = 0 2 w/ p/ p' J1 B; x. e
]
6 M! Q& m! t4 u; j: m: S7 ^ifelse any? close-mates / \* J& l7 R- @& C! D' Y' X! q
[
# Y8 g3 @( { nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, {8 B4 h4 k# Q& h6 M8 Uface closest-one
/ P- l7 E% W5 o6 }( J& o. }0 }rt 180! a( ^. f' H9 ^* E
fd random-float step-size
0 C% H, r9 R3 g( F+ i: q3 A0 ?avoid-walls; ?7 I! y9 }6 E' q" S
set stopped? false]
- A: M% [5 Q% M7 w% }9 X[set stopped? true]
# K, v* K3 [1 L7 a; u2 X7 n9 j] |
|