|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ {- ?3 I4 R F/ C6 Y3 X
to go- M9 J. Z9 d: w, K5 z' W; W
if not any? turtles with [not stopped? ] [ stop ] 3 n8 t( ]0 F. t. L8 Q$ J' n# a( {; m
ask turtles with [remainder who 5 = 0] [
i. D. S/ P: c0 l5 Hset close-mates (turtles with [self != myself])with[
0 m/ _, l$ `) A) t(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% n- Y3 }* p* w' x8 hand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ' g% h5 } S3 K+ Y3 k
and remainder who 5 = 0
+ L/ `1 o- M, _]
4 s- K/ o" V3 Q7 O3 Sifelse any? close-mates 6 Z2 Y" s; d2 v+ B; U; z0 V
[
s( E* m2 {) M- U4 r- f8 N sset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
; `$ p0 Z Y4 D) M, j! yface closest-one7 B% G$ J1 U, \, k- B5 u2 ]
rt 180. B6 ^* @1 a; A, a
fd random-float step-size
$ z% O2 n) t7 J$ T8 N% M2 Z! D* ~9 K- P. davoid-walls
% o# ^& E* i6 i8 f6 b eset stopped? false]
3 P: u; Z# m& E' j[set stopped? true]
! R# p. K' w, o* U] |
|