|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
( B" v. D& r3 L! B$ }to go5 B6 P [2 y2 u: G8 u1 o
if not any? turtles with [not stopped? ] [ stop ]
. A8 k1 E- c' U( z$ `ask turtles with [remainder who 5 = 0] [
" l; G$ ~5 k. O. sset close-mates (turtles with [self != myself])with[
- k* L! B5 M( t% k1 n(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( w# Z3 [+ v! P- G" H. ^# \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
' i* H! o7 z/ s+ `- a l1 J3 Vand remainder who 5 = 0 ( G1 M; a! Z1 R% D
] , Y& b, d, |9 F' U0 @
ifelse any? close-mates ( W, u9 w B5 k1 v7 W c0 |5 q: f
[
1 b5 P) q/ ^6 c9 N3 W, Fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 y s8 W" v* }; pface closest-one
u) [5 }) @! ~+ }rt 180
* |/ \. m/ s) ]& {% _/ Rfd random-float step-size
! V Z: E) @0 t7 gavoid-walls6 l- \) \: _6 X# q+ g+ e
set stopped? false]
) n' O' o9 Y! t; M( G8 H+ d[set stopped? true]
& H2 E S0 c1 ^* d' r] |
|