|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
1 ^; ]: `9 }$ V% N" J0 Oto go
2 D( o/ I8 t1 a" n" E4 a. fif not any? turtles with [not stopped? ] [ stop ]
: b8 C. k: U. e0 `ask turtles with [remainder who 5 = 0] [) T" H" a+ W3 C8 L
set close-mates (turtles with [self != myself])with[
" t }0 q+ K3 A) v. I(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
7 Y2 ~2 ?/ z, } H7 t8 b4 l Iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( J; d2 w1 G- |6 Kand remainder who 5 = 0 % m& p9 e; \. K! A. C
]
9 y' H, P9 D+ i! c. wifelse any? close-mates
; {2 S/ I6 t* ?[ 3 n/ E+ i0 R: m1 N' g- G
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]% O% W. s, K2 T7 s2 U+ p# _, I1 k
face closest-one
* B" l$ x6 O4 r, _rt 180
# J; G4 T5 |. p [% S3 N S. d% [fd random-float step-size+ F* u: w! ?( W) O$ @1 u
avoid-walls
/ l; _5 b! p4 f" ~1 ?# c# bset stopped? false]
$ ~8 [. Q8 k2 ?& I[set stopped? true] 4 J* K, N- n, \
] |
|