|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
M- d/ ?: E0 Sto go- Z8 Z( W1 {# f
if not any? turtles with [not stopped? ] [ stop ] - |2 ^2 S. ^( v2 `* |
ask turtles with [remainder who 5 = 0] [5 U0 }( W$ o6 G2 w8 e% x8 n
set close-mates (turtles with [self != myself])with[$ }* P. W6 l8 Q
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 F; D3 ]! h# ?! t: Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 Y$ E, }/ s1 N% f, i6 ?* O* Kand remainder who 5 = 0
6 N. V, x" ]; T i2 K! C] : W$ y( ~% B& B6 C3 [
ifelse any? close-mates
( C8 H1 `2 B5 g5 u4 v5 }4 z; k" L[
* I, D( y" ?' hset closest-one min-one-of (close-mates with[self != myself] )[distance myself]3 H" i2 d5 g0 L# J* A$ K
face closest-one
R$ [. }7 a% ~. I* ?5 Drt 180, B' ?5 s+ Z5 I* e1 r: Q$ I. e
fd random-float step-size
8 c9 |- W* L0 M6 P8 e6 aavoid-walls
3 L, E! I4 l% O0 b+ T! ^set stopped? false]0 I7 T( @$ G) W1 w; H( ]( H
[set stopped? true]
! @$ e& |7 M# }/ w" F] |
|