|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' ~! i5 C! n' a& z: S O$ z K) Gto go
! o# c" i- @. a9 Qif not any? turtles with [not stopped? ] [ stop ] h( n. G7 I( t& c# J% ?3 G
ask turtles with [remainder who 5 = 0] [
, o! R8 k9 \6 a, l |3 gset close-mates (turtles with [self != myself])with[' f, K( p0 r! S, Y) V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& s& c( {4 [. a' s! s! Z9 Eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
$ W! y; O' ?4 Cand remainder who 5 = 0 9 H; k- \6 K2 W* y; J; K2 a
] ; _' h: K. n* Y; ^. f) o
ifelse any? close-mates
1 i( A/ U% o" r; {3 Z[
; K' m, x4 a7 x* T2 T' e$ p; Eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]# b7 G3 l+ T; L6 }) D( t, r6 \+ t
face closest-one1 G1 q7 J( K1 Z
rt 180& J# O7 N" {. @4 k4 _7 D7 {
fd random-float step-size' c2 k7 K% p6 J( h U
avoid-walls7 j# W5 u. {, B! A- t/ k0 q, k
set stopped? false]/ @3 y0 |. P p! s
[set stopped? true] 2 p4 \/ d D0 t8 C. r
] |
|