|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false! W+ l$ {0 B2 l
to go$ w2 c- G* d8 C
if not any? turtles with [not stopped? ] [ stop ] ; R, ^1 V/ `- U7 t! f% l; h8 j C
ask turtles with [remainder who 5 = 0] [, E0 D6 q$ T" x( D" ]
set close-mates (turtles with [self != myself])with[
2 ]; M$ ]* c4 h+ ?# _2 B' X3 g(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
+ e& I. ?( b7 x/ A5 [7 tand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) # v8 U5 V X( c2 B
and remainder who 5 = 0 ( ]- W4 u9 H t4 l2 `' J
] / q T; m" b8 s- X+ \; f' _
ifelse any? close-mates " i" n. n) A5 m3 l
[
8 P5 ~- _, t; k5 ]$ Zset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
" u, Y2 E5 d$ N. H5 O, uface closest-one+ r# M v! W- C5 }
rt 1804 ]" L0 l" l" _5 J( K/ F) ]* m
fd random-float step-size4 c" Q" ?, p: }; {1 o
avoid-walls
. r# f) Q& U$ X1 l, iset stopped? false]) V* _$ w2 g7 I2 ]$ A
[set stopped? true]
) O. F# y6 H% `+ z5 y] |
|