Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_15_03.adf » !AcornAns_AcornAns » Flocking/Basic/Old/Flock4

Flocking/Basic/Old/Flock4

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_15_03.adf » !AcornAns_AcornAns
Filename: Flocking/Basic/Old/Flock4
Read OK:
File size: 0C3F bytes
Load address: 0000
Exec address: 0000
File contents
   10REM Not flocking working
   20:
   30n%=16
   40G%=4
   50RC%=5*G%    :REM collision distance
   60RM%=8*G%    :REM velocity matching distance
   70RL%=40*G%   :REM local distance
   80:
   90pn%=4
  100DIM px(pn%-1), py(pn%-1), pr(pn%-1), pr2(pn%-1)
  110RESTORE
  120FOR i%=0 TO pn%-1
  130 READ px(i%),py(i%),pr(i%)
  140 pr2(i%)=(pr(i%)+RC%/2)*(pr(i%)+RC%/2)
  150NEXT
  160DATA -300,0,40, -100,50,20, 300,-50,5, 640,0,40
  170:
  180RL2%=RL%*RL%
  190DIM x(n%-1), y(n%-1)
  200DIM xn(n%-1), yn(n%-1)
  210DIM vx(n%-1), vy(n%-1), mv(n%-1)
  220DIM dm(n%-1), im%(n%-1)
  230DIM ax(n%-1), ay(n%-1)
  240DIM avx(n%-1), avy(n%-1)
  250DIM ac%(n%-1)
  260:
  270MODE 18:OFF
  280ORIGIN 640,512
  290:
  300p%=125*G%
  310v%=G%*4
  320FOR i%=0 TO n%-1
  330 x(i%)=RND(p%)-p%/2
  340 y(i%)=RND(p%)-p%/2
  350 vx(i%)=RND(1)*v%
  360 vy(i%)=RND(1)*v%-v%/2
  370 f=SQR(vx(i%)*vx(i%)+vy(i%)*vy(i%)):IF f<0.001 f=0.001
  380 mv(i%)=f
  390NEXT
  400:
  410REPEAT
  420 IF INKEY-99 RUN
  430 WAIT
  440 CLS
  450 FOR i%=0 TO n%-1
  460  LINE x(i%),y(i%),x(i%)+vx(i%)*8/mv(i%),y(i%)+vy(i%)*8/mv(i%)
  470 NEXT
  480 FOR i%=0 TO pn%-1
  490  CIRCLE px(i%),py(i%),pr(i%)
  500 NEXT
  510 PROCmove
  520 FOR i%=0 TO n%-1
  530  x(i%)=xn(i%)
  540  y(i%)=yn(i%)
  550 NEXT
  560UNTIL 0
  570:
  580END
  590:
  600:
  610DEF PROCmove
  620:
  630FOR i%=0 TO n%-1
  640 dm(i%)=1E20
  650REM ax(i%)=x(i%)
  660REM ay(i%)=y(i%)
  670REM avx(i%)=vx(i%)
  680REM avy(i%)=vy(i%)
  690REM ac%(i%)=1
  700ax(i%)=0
  710ay(i%)=0
  720avx(i%)=0
  730avy(i%)=0
  740ac%(i%)=0
  750NEXT
  760:
  770FOR i%=0 TO n%-2
  780 FOR j%=i%+1 TO n%-1
  790  d = (x(i%)-x(j%))*(x(i%)-x(j%)) + (y(i%)-y(j%))*(y(i%)-y(j%))
  800  IF d<dm(i%) dm(i%)=d:im%(i%)=j%
  810  IF d<dm(j%) dm(j%)=d:im%(j%)=i%
  820  IF d<RL2% THEN
  830   ax(i%)+=x(j%):ay(i%)+=y(j%):avx(i%)+=vx(j%):avy(i%)+=vy(j%):ac%(i%)+=1
  840   ax(j%)+=x(i%):ay(j%)+=y(i%):avx(j%)+=vx(i%):avy(j%)+=vy(i%):ac%(j%)+=1
  850  ENDIF
  860 NEXT
  870NEXT
  880:
  890FOR i%=0 TO n%-1
  900 IF dm(i%)>=RL2% THEN
  910  ax(i%)+=x(im%(i%)):ay(i%)+=y(im%(i%))
  920  avx(i%)+=vx(im%(i%)):avy(i%)+=vy(im%(i%))
  930  ac%(i%)+=1
  940 ENDIF
  950
  960 vx=vx(i%):vy=vy(i%)
  970 x=x(i%):y=y(i%)
  980 FOR j%=0 TO pn%-1
  990  pd=(px(j%)-x)*(px(j%)-x)+(py(j%)-y)*(py(j%)-y)
 1000  IF pd<pr2(j%) j%+=&10000
 1010 NEXT
 1020 IF j%AND&10000 THEN
 1030  j%-=&10001
 1040  pd=SQRpd:IF pd<0.001 pd=0.001
 1050  u=(px(j%)-x)/pd
 1060  v=(py(j%)-y)/pd
 1070  sp=2*(u*vx+v*vy)
 1080  IF sp>0 THEN
 1090   vx-=sp*u
 1100   vy-=sp*v
 1110  ENDIF
 1120 ELSE
 1130  IF x(i%)<RC%-640 OR x(i%)>640-RC% OR y(i%)<RC%-512 OR y(i%)>512-RC% THEN
 1140   IF x(i%)<RC%-640 AND vx<0 vx=-vx
 1150   IF x(i%)>640-RC% AND vx>0 vx=-vx
 1160   IF y(i%)<RC%-512 AND vy<0 vy=-vy
 1170   IF y(i%)>512-RC% AND vy>0 vy=-vy
 1180  ELSE
 1190   d=SQRdm(i%):IF d<0.001 d=0.001
 1200   IF d<RC% THEN
 1210    u=(x(im%(i%))-x(i%))/d
 1220    v=(y(im%(i%))-y(i%))/d
 1230    sp=2*(u*vx+v*vy)
 1240    IF sp>0 THEN
 1250     vx-=sp*u
 1260     vy-=sp*v
 1270    ENDIF
 1280   ELSE
 1290    IF d<RM% THEN
 1300     vx=avx(i%)/ac%(i%)
 1310     vy=avy(i%)/ac%(i%)
 1320    ELSE
 1330     ax(i%)=ax(i%)/ac%(i%)
 1340     ay(i%)=ay(i%)/ac%(i%)
 1350     dc=SQR( (ax(i%)-x(i%))*(ax(i%)-x(i%)) + (ay(i%)-y(i%))*(ay(i%)-y(i%)) ):IF dc<0.001 dc=0.001
 1360     a=(ax(i%)-x(i%))/dc
 1370     b=(ay(i%)-y(i%))/dc
 1380     vx=a*G%*d/RM%
 1390     vy=b*G%*d/RM%
 1400    ENDIF
 1410   ENDIF
 1420  ENDIF
 1430 ENDIF
 1440 f=SQR(vx*vx+vy*vy):IF f<0.001 f=0.001
 1450 IF f<G%*G% THEN
 1460  vx=vx*G%/f
 1470  vy=vy*G%/f
 1480  f=G%
 1490 ENDIF
 1500 xn(i%)=x(i%)+vx
 1510 yn(i%)=y(i%)+vy
 1520 vx(i%)=vx
 1530 vy(i%)=vy
 1540 mv(i%)=f
 1550NEXT
 1560:
 1570ENDPROC

� Not flocking working
:
	n%=16
(G%=4
2%RC%=5*G%    :� collision distance
<-RM%=8*G%    :� velocity matching distance
F!RL%=40*G%   :� local distance
P:
Z	pn%=4
d1� px(pn%-1), py(pn%-1), pr(pn%-1), pr2(pn%-1)
n�
x� i%=0 � pn%-1
� � px(i%),py(i%),pr(i%)
�* pr2(i%)=(pr(i%)+RC%/2)*(pr(i%)+RC%/2)
��
�0� -300,0,40, -100,50,20, 300,-50,5, 640,0,40
�:
�RL2%=RL%*RL%
�� x(n%-1), y(n%-1)
�� xn(n%-1), yn(n%-1)
�"� vx(n%-1), vy(n%-1), mv(n%-1)
�� dm(n%-1), im%(n%-1)
�� ax(n%-1), ay(n%-1)
�� avx(n%-1), avy(n%-1)
�� ac%(n%-1)
:

� 18:�
ȑ 640,512
":
,
p%=125*G%
6v%=G%*4
@� i%=0 � n%-1
J x(i%)=�(p%)-p%/2
T y(i%)=�(p%)-p%/2
^ vx(i%)=�(1)*v%
h vy(i%)=�(1)*v%-v%/2
r7 f=�(vx(i%)*vx(i%)+vy(i%)*vy(i%)):� f<0.001 f=0.001
|
 mv(i%)=f
��
�:
��
�
 � �-99 �
� Ȗ
� �
� � i%=0 � n%-1
�?  � x(i%),y(i%),x(i%)+vx(i%)*8/mv(i%),y(i%)+vy(i%)*8/mv(i%)
� �
� � i%=0 � pn%-1
�  ȏ px(i%),py(i%),pr(i%)
� �
�
 �move
 � i%=0 � n%-1
  x(i%)=xn(i%)
  y(i%)=yn(i%)
& �
0� 0
::
D�
N:
X:
b� �move
l:
v� i%=0 � n%-1
� dm(i%)=1E20
�� ax(i%)=x(i%)
�� ay(i%)=y(i%)
�� avx(i%)=vx(i%)
�� avy(i%)=vy(i%)
�� ac%(i%)=1
�ax(i%)=0
�ay(i%)=0
�
avx(i%)=0
�
avy(i%)=0
�
ac%(i%)=0
��
�:
� i%=0 � n%-2
 � j%=i%+1 � n%-1
C  d = (x(i%)-x(j%))*(x(i%)-x(j%)) + (y(i%)-y(j%))*(y(i%)-y(j%))
 $  � d<dm(i%) dm(i%)=d:im%(i%)=j%
*$  � d<dm(j%) dm(j%)=d:im%(j%)=i%
4  � d<RL2% �
>M   ax(i%)+=x(j%):ay(i%)+=y(j%):avx(i%)+=vx(j%):avy(i%)+=vy(j%):ac%(i%)+=1
HM   ax(j%)+=x(i%):ay(j%)+=y(i%):avx(j%)+=vx(i%):avy(j%)+=vy(i%):ac%(j%)+=1
R  �
\ �
f�
p:
z� i%=0 � n%-1
� � dm(i%)>=RL2% �
�+  ax(i%)+=x(im%(i%)):ay(i%)+=y(im%(i%))
�/  avx(i%)+=vx(im%(i%)):avy(i%)+=vy(im%(i%))
�  ac%(i%)+=1
� �
�
� vx=vx(i%):vy=vy(i%)
� x=x(i%):y=y(i%)
� � j%=0 � pn%-1
�4  pd=(px(j%)-x)*(px(j%)-x)+(py(j%)-y)*(py(j%)-y)
�  � pd<pr2(j%) j%+=&10000
� �
� � j%�&10000 �
  j%-=&10001
   pd=�pd:� pd<0.001 pd=0.001
  u=(px(j%)-x)/pd
$  v=(py(j%)-y)/pd
.  sp=2*(u*vx+v*vy)
8  � sp>0 �
B   vx-=sp*u
L   vy-=sp*v
V  �
` �
jG  � x(i%)<RC%-640 � x(i%)>640-RC% � y(i%)<RC%-512 � y(i%)>512-RC% �
t$   � x(i%)<RC%-640 � vx<0 vx=-vx
~$   � x(i%)>640-RC% � vx>0 vx=-vx
�$   � y(i%)<RC%-512 � vy<0 vy=-vy
�$   � y(i%)>512-RC% � vy>0 vy=-vy
�  �
�"   d=�dm(i%):� d<0.001 d=0.001
�   � d<RC% �
�    u=(x(im%(i%))-x(i%))/d
�    v=(y(im%(i%))-y(i%))/d
�    sp=2*(u*vx+v*vy)
�    � sp>0 �
�     vx-=sp*u
�     vy-=sp*v
�	    �
   �

    � d<RM% �
     vx=avx(i%)/ac%(i%)
     vy=avy(i%)/ac%(i%)
(	    �
2     ax(i%)=ax(i%)/ac%(i%)
<     ay(i%)=ay(i%)/ac%(i%)
Fb     dc=�( (ax(i%)-x(i%))*(ax(i%)-x(i%)) + (ay(i%)-y(i%))*(ay(i%)-y(i%)) ):� dc<0.001 dc=0.001
P     a=(ax(i%)-x(i%))/dc
Z     b=(ay(i%)-y(i%))/dc
d     vx=a*G%*d/RM%
n     vy=b*G%*d/RM%
x	    �
�   �
�  �
� �
�' f=�(vx*vx+vy*vy):� f<0.001 f=0.001
� � f<G%*G% �
�  vx=vx*G%/f
�  vy=vy*G%/f
�
  f=G%
� �
� xn(i%)=x(i%)+vx
� yn(i%)=y(i%)+vy
� vx(i%)=vx
� vy(i%)=vy

 mv(i%)=f
�
:
"�
�
00000000  0d 00 0a 1a f4 20 4e 6f  74 20 66 6c 6f 63 6b 69  |..... Not flocki|
00000010  6e 67 20 77 6f 72 6b 69  6e 67 0d 00 14 05 3a 0d  |ng working....:.|
00000020  00 1e 09 6e 25 3d 31 36  0d 00 28 08 47 25 3d 34  |...n%=16..(.G%=4|
00000030  0d 00 32 25 52 43 25 3d  35 2a 47 25 20 20 20 20  |..2%RC%=5*G%    |
00000040  3a f4 20 63 6f 6c 6c 69  73 69 6f 6e 20 64 69 73  |:. collision dis|
00000050  74 61 6e 63 65 0d 00 3c  2d 52 4d 25 3d 38 2a 47  |tance..<-RM%=8*G|
00000060  25 20 20 20 20 3a f4 20  76 65 6c 6f 63 69 74 79  |%    :. velocity|
00000070  20 6d 61 74 63 68 69 6e  67 20 64 69 73 74 61 6e  | matching distan|
00000080  63 65 0d 00 46 21 52 4c  25 3d 34 30 2a 47 25 20  |ce..F!RL%=40*G% |
00000090  20 20 3a f4 20 6c 6f 63  61 6c 20 64 69 73 74 61  |  :. local dista|
000000a0  6e 63 65 0d 00 50 05 3a  0d 00 5a 09 70 6e 25 3d  |nce..P.:..Z.pn%=|
000000b0  34 0d 00 64 31 de 20 70  78 28 70 6e 25 2d 31 29  |4..d1. px(pn%-1)|
000000c0  2c 20 70 79 28 70 6e 25  2d 31 29 2c 20 70 72 28  |, py(pn%-1), pr(|
000000d0  70 6e 25 2d 31 29 2c 20  70 72 32 28 70 6e 25 2d  |pn%-1), pr2(pn%-|
000000e0  31 29 0d 00 6e 05 f7 0d  00 78 12 e3 20 69 25 3d  |1)..n....x.. i%=|
000000f0  30 20 b8 20 70 6e 25 2d  31 0d 00 82 1b 20 f3 20  |0 . pn%-1.... . |
00000100  70 78 28 69 25 29 2c 70  79 28 69 25 29 2c 70 72  |px(i%),py(i%),pr|
00000110  28 69 25 29 0d 00 8c 2a  20 70 72 32 28 69 25 29  |(i%)...* pr2(i%)|
00000120  3d 28 70 72 28 69 25 29  2b 52 43 25 2f 32 29 2a  |=(pr(i%)+RC%/2)*|
00000130  28 70 72 28 69 25 29 2b  52 43 25 2f 32 29 0d 00  |(pr(i%)+RC%/2)..|
00000140  96 05 ed 0d 00 a0 30 dc  20 2d 33 30 30 2c 30 2c  |......0. -300,0,|
00000150  34 30 2c 20 2d 31 30 30  2c 35 30 2c 32 30 2c 20  |40, -100,50,20, |
00000160  33 30 30 2c 2d 35 30 2c  35 2c 20 36 34 30 2c 30  |300,-50,5, 640,0|
00000170  2c 34 30 0d 00 aa 05 3a  0d 00 b4 10 52 4c 32 25  |,40....:....RL2%|
00000180  3d 52 4c 25 2a 52 4c 25  0d 00 be 16 de 20 78 28  |=RL%*RL%..... x(|
00000190  6e 25 2d 31 29 2c 20 79  28 6e 25 2d 31 29 0d 00  |n%-1), y(n%-1)..|
000001a0  c8 18 de 20 78 6e 28 6e  25 2d 31 29 2c 20 79 6e  |... xn(n%-1), yn|
000001b0  28 6e 25 2d 31 29 0d 00  d2 22 de 20 76 78 28 6e  |(n%-1)...". vx(n|
000001c0  25 2d 31 29 2c 20 76 79  28 6e 25 2d 31 29 2c 20  |%-1), vy(n%-1), |
000001d0  6d 76 28 6e 25 2d 31 29  0d 00 dc 19 de 20 64 6d  |mv(n%-1)..... dm|
000001e0  28 6e 25 2d 31 29 2c 20  69 6d 25 28 6e 25 2d 31  |(n%-1), im%(n%-1|
000001f0  29 0d 00 e6 18 de 20 61  78 28 6e 25 2d 31 29 2c  |)..... ax(n%-1),|
00000200  20 61 79 28 6e 25 2d 31  29 0d 00 f0 1a de 20 61  | ay(n%-1)..... a|
00000210  76 78 28 6e 25 2d 31 29  2c 20 61 76 79 28 6e 25  |vx(n%-1), avy(n%|
00000220  2d 31 29 0d 00 fa 0f de  20 61 63 25 28 6e 25 2d  |-1)..... ac%(n%-|
00000230  31 29 0d 01 04 05 3a 0d  01 0e 0a eb 20 31 38 3a  |1)....:..... 18:|
00000240  87 0d 01 18 0e c8 91 20  36 34 30 2c 35 31 32 0d  |....... 640,512.|
00000250  01 22 05 3a 0d 01 2c 0d  70 25 3d 31 32 35 2a 47  |.".:..,.p%=125*G|
00000260  25 0d 01 36 0b 76 25 3d  47 25 2a 34 0d 01 40 11  |%..6.v%=G%*4..@.|
00000270  e3 20 69 25 3d 30 20 b8  20 6e 25 2d 31 0d 01 4a  |. i%=0 . n%-1..J|
00000280  15 20 78 28 69 25 29 3d  b3 28 70 25 29 2d 70 25  |. x(i%)=.(p%)-p%|
00000290  2f 32 0d 01 54 15 20 79  28 69 25 29 3d b3 28 70  |/2..T. y(i%)=.(p|
000002a0  25 29 2d 70 25 2f 32 0d  01 5e 13 20 76 78 28 69  |%)-p%/2..^. vx(i|
000002b0  25 29 3d b3 28 31 29 2a  76 25 0d 01 68 18 20 76  |%)=.(1)*v%..h. v|
000002c0  79 28 69 25 29 3d b3 28  31 29 2a 76 25 2d 76 25  |y(i%)=.(1)*v%-v%|
000002d0  2f 32 0d 01 72 37 20 66  3d b6 28 76 78 28 69 25  |/2..r7 f=.(vx(i%|
000002e0  29 2a 76 78 28 69 25 29  2b 76 79 28 69 25 29 2a  |)*vx(i%)+vy(i%)*|
000002f0  76 79 28 69 25 29 29 3a  e7 20 66 3c 30 2e 30 30  |vy(i%)):. f<0.00|
00000300  31 20 66 3d 30 2e 30 30  31 0d 01 7c 0d 20 6d 76  |1 f=0.001..|. mv|
00000310  28 69 25 29 3d 66 0d 01  86 05 ed 0d 01 90 05 3a  |(i%)=f.........:|
00000320  0d 01 9a 05 f5 0d 01 a4  0d 20 e7 20 a6 2d 39 39  |......... . .-99|
00000330  20 f9 0d 01 ae 07 20 c8  96 0d 01 b8 06 20 db 0d  | ..... ...... ..|
00000340  01 c2 12 20 e3 20 69 25  3d 30 20 b8 20 6e 25 2d  |... . i%=0 . n%-|
00000350  31 0d 01 cc 3f 20 20 86  20 78 28 69 25 29 2c 79  |1...?  . x(i%),y|
00000360  28 69 25 29 2c 78 28 69  25 29 2b 76 78 28 69 25  |(i%),x(i%)+vx(i%|
00000370  29 2a 38 2f 6d 76 28 69  25 29 2c 79 28 69 25 29  |)*8/mv(i%),y(i%)|
00000380  2b 76 79 28 69 25 29 2a  38 2f 6d 76 28 69 25 29  |+vy(i%)*8/mv(i%)|
00000390  0d 01 d6 06 20 ed 0d 01  e0 13 20 e3 20 69 25 3d  |.... ..... . i%=|
000003a0  30 20 b8 20 70 6e 25 2d  31 0d 01 ea 1d 20 20 c8  |0 . pn%-1....  .|
000003b0  8f 20 70 78 28 69 25 29  2c 70 79 28 69 25 29 2c  |. px(i%),py(i%),|
000003c0  70 72 28 69 25 29 0d 01  f4 06 20 ed 0d 01 fe 0a  |pr(i%).... .....|
000003d0  20 f2 6d 6f 76 65 0d 02  08 12 20 e3 20 69 25 3d  | .move.... . i%=|
000003e0  30 20 b8 20 6e 25 2d 31  0d 02 12 12 20 20 78 28  |0 . n%-1....  x(|
000003f0  69 25 29 3d 78 6e 28 69  25 29 0d 02 1c 12 20 20  |i%)=xn(i%)....  |
00000400  79 28 69 25 29 3d 79 6e  28 69 25 29 0d 02 26 06  |y(i%)=yn(i%)..&.|
00000410  20 ed 0d 02 30 07 fd 20  30 0d 02 3a 05 3a 0d 02  | ...0.. 0..:.:..|
00000420  44 05 e0 0d 02 4e 05 3a  0d 02 58 05 3a 0d 02 62  |D....N.:..X.:..b|
00000430  0b dd 20 f2 6d 6f 76 65  0d 02 6c 05 3a 0d 02 76  |.. .move..l.:..v|
00000440  11 e3 20 69 25 3d 30 20  b8 20 6e 25 2d 31 0d 02  |.. i%=0 . n%-1..|
00000450  80 10 20 64 6d 28 69 25  29 3d 31 45 32 30 0d 02  |.. dm(i%)=1E20..|
00000460  8a 12 f4 20 61 78 28 69  25 29 3d 78 28 69 25 29  |... ax(i%)=x(i%)|
00000470  0d 02 94 12 f4 20 61 79  28 69 25 29 3d 79 28 69  |..... ay(i%)=y(i|
00000480  25 29 0d 02 9e 14 f4 20  61 76 78 28 69 25 29 3d  |%)..... avx(i%)=|
00000490  76 78 28 69 25 29 0d 02  a8 14 f4 20 61 76 79 28  |vx(i%)..... avy(|
000004a0  69 25 29 3d 76 79 28 69  25 29 0d 02 b2 0f f4 20  |i%)=vy(i%)..... |
000004b0  61 63 25 28 69 25 29 3d  31 0d 02 bc 0c 61 78 28  |ac%(i%)=1....ax(|
000004c0  69 25 29 3d 30 0d 02 c6  0c 61 79 28 69 25 29 3d  |i%)=0....ay(i%)=|
000004d0  30 0d 02 d0 0d 61 76 78  28 69 25 29 3d 30 0d 02  |0....avx(i%)=0..|
000004e0  da 0d 61 76 79 28 69 25  29 3d 30 0d 02 e4 0d 61  |..avy(i%)=0....a|
000004f0  63 25 28 69 25 29 3d 30  0d 02 ee 05 ed 0d 02 f8  |c%(i%)=0........|
00000500  05 3a 0d 03 02 11 e3 20  69 25 3d 30 20 b8 20 6e  |.:..... i%=0 . n|
00000510  25 2d 32 0d 03 0c 15 20  e3 20 6a 25 3d 69 25 2b  |%-2.... . j%=i%+|
00000520  31 20 b8 20 6e 25 2d 31  0d 03 16 43 20 20 64 20  |1 . n%-1...C  d |
00000530  3d 20 28 78 28 69 25 29  2d 78 28 6a 25 29 29 2a  |= (x(i%)-x(j%))*|
00000540  28 78 28 69 25 29 2d 78  28 6a 25 29 29 20 2b 20  |(x(i%)-x(j%)) + |
00000550  28 79 28 69 25 29 2d 79  28 6a 25 29 29 2a 28 79  |(y(i%)-y(j%))*(y|
00000560  28 69 25 29 2d 79 28 6a  25 29 29 0d 03 20 24 20  |(i%)-y(j%)).. $ |
00000570  20 e7 20 64 3c 64 6d 28  69 25 29 20 64 6d 28 69  | . d<dm(i%) dm(i|
00000580  25 29 3d 64 3a 69 6d 25  28 69 25 29 3d 6a 25 0d  |%)=d:im%(i%)=j%.|
00000590  03 2a 24 20 20 e7 20 64  3c 64 6d 28 6a 25 29 20  |.*$  . d<dm(j%) |
000005a0  64 6d 28 6a 25 29 3d 64  3a 69 6d 25 28 6a 25 29  |dm(j%)=d:im%(j%)|
000005b0  3d 69 25 0d 03 34 10 20  20 e7 20 64 3c 52 4c 32  |=i%..4.  . d<RL2|
000005c0  25 20 8c 0d 03 3e 4d 20  20 20 61 78 28 69 25 29  |% ...>M   ax(i%)|
000005d0  2b 3d 78 28 6a 25 29 3a  61 79 28 69 25 29 2b 3d  |+=x(j%):ay(i%)+=|
000005e0  79 28 6a 25 29 3a 61 76  78 28 69 25 29 2b 3d 76  |y(j%):avx(i%)+=v|
000005f0  78 28 6a 25 29 3a 61 76  79 28 69 25 29 2b 3d 76  |x(j%):avy(i%)+=v|
00000600  79 28 6a 25 29 3a 61 63  25 28 69 25 29 2b 3d 31  |y(j%):ac%(i%)+=1|
00000610  0d 03 48 4d 20 20 20 61  78 28 6a 25 29 2b 3d 78  |..HM   ax(j%)+=x|
00000620  28 69 25 29 3a 61 79 28  6a 25 29 2b 3d 79 28 69  |(i%):ay(j%)+=y(i|
00000630  25 29 3a 61 76 78 28 6a  25 29 2b 3d 76 78 28 69  |%):avx(j%)+=vx(i|
00000640  25 29 3a 61 76 79 28 6a  25 29 2b 3d 76 79 28 69  |%):avy(j%)+=vy(i|
00000650  25 29 3a 61 63 25 28 6a  25 29 2b 3d 31 0d 03 52  |%):ac%(j%)+=1..R|
00000660  07 20 20 cd 0d 03 5c 06  20 ed 0d 03 66 05 ed 0d  |.  ...\. ...f...|
00000670  03 70 05 3a 0d 03 7a 11  e3 20 69 25 3d 30 20 b8  |.p.:..z.. i%=0 .|
00000680  20 6e 25 2d 31 0d 03 84  15 20 e7 20 64 6d 28 69  | n%-1.... . dm(i|
00000690  25 29 3e 3d 52 4c 32 25  20 8c 0d 03 8e 2b 20 20  |%)>=RL2% ....+  |
000006a0  61 78 28 69 25 29 2b 3d  78 28 69 6d 25 28 69 25  |ax(i%)+=x(im%(i%|
000006b0  29 29 3a 61 79 28 69 25  29 2b 3d 79 28 69 6d 25  |)):ay(i%)+=y(im%|
000006c0  28 69 25 29 29 0d 03 98  2f 20 20 61 76 78 28 69  |(i%)).../  avx(i|
000006d0  25 29 2b 3d 76 78 28 69  6d 25 28 69 25 29 29 3a  |%)+=vx(im%(i%)):|
000006e0  61 76 79 28 69 25 29 2b  3d 76 79 28 69 6d 25 28  |avy(i%)+=vy(im%(|
000006f0  69 25 29 29 0d 03 a2 10  20 20 61 63 25 28 69 25  |i%))....  ac%(i%|
00000700  29 2b 3d 31 0d 03 ac 06  20 cd 0d 03 b6 04 0d 03  |)+=1.... .......|
00000710  c0 18 20 76 78 3d 76 78  28 69 25 29 3a 76 79 3d  |.. vx=vx(i%):vy=|
00000720  76 79 28 69 25 29 0d 03  ca 14 20 78 3d 78 28 69  |vy(i%).... x=x(i|
00000730  25 29 3a 79 3d 79 28 69  25 29 0d 03 d4 13 20 e3  |%):y=y(i%).... .|
00000740  20 6a 25 3d 30 20 b8 20  70 6e 25 2d 31 0d 03 de  | j%=0 . pn%-1...|
00000750  34 20 20 70 64 3d 28 70  78 28 6a 25 29 2d 78 29  |4  pd=(px(j%)-x)|
00000760  2a 28 70 78 28 6a 25 29  2d 78 29 2b 28 70 79 28  |*(px(j%)-x)+(py(|
00000770  6a 25 29 2d 79 29 2a 28  70 79 28 6a 25 29 2d 79  |j%)-y)*(py(j%)-y|
00000780  29 0d 03 e8 1d 20 20 e7  20 70 64 3c 70 72 32 28  |)....  . pd<pr2(|
00000790  6a 25 29 20 6a 25 2b 3d  26 31 30 30 30 30 0d 03  |j%) j%+=&10000..|
000007a0  f2 06 20 ed 0d 03 fc 12  20 e7 20 6a 25 80 26 31  |.. ..... . j%.&1|
000007b0  30 30 30 30 20 8c 0d 04  06 10 20 20 6a 25 2d 3d  |0000 .....  j%-=|
000007c0  26 31 30 30 30 31 0d 04  10 20 20 20 70 64 3d b6  |&10001...   pd=.|
000007d0  70 64 3a e7 20 70 64 3c  30 2e 30 30 31 20 70 64  |pd:. pd<0.001 pd|
000007e0  3d 30 2e 30 30 31 0d 04  1a 15 20 20 75 3d 28 70  |=0.001....  u=(p|
000007f0  78 28 6a 25 29 2d 78 29  2f 70 64 0d 04 24 15 20  |x(j%)-x)/pd..$. |
00000800  20 76 3d 28 70 79 28 6a  25 29 2d 79 29 2f 70 64  | v=(py(j%)-y)/pd|
00000810  0d 04 2e 16 20 20 73 70  3d 32 2a 28 75 2a 76 78  |....  sp=2*(u*vx|
00000820  2b 76 2a 76 79 29 0d 04  38 0e 20 20 e7 20 73 70  |+v*vy)..8.  . sp|
00000830  3e 30 20 8c 0d 04 42 0f  20 20 20 76 78 2d 3d 73  |>0 ...B.   vx-=s|
00000840  70 2a 75 0d 04 4c 0f 20  20 20 76 79 2d 3d 73 70  |p*u..L.   vy-=sp|
00000850  2a 76 0d 04 56 07 20 20  cd 0d 04 60 06 20 cc 0d  |*v..V.  ...`. ..|
00000860  04 6a 47 20 20 e7 20 78  28 69 25 29 3c 52 43 25  |.jG  . x(i%)<RC%|
00000870  2d 36 34 30 20 84 20 78  28 69 25 29 3e 36 34 30  |-640 . x(i%)>640|
00000880  2d 52 43 25 20 84 20 79  28 69 25 29 3c 52 43 25  |-RC% . y(i%)<RC%|
00000890  2d 35 31 32 20 84 20 79  28 69 25 29 3e 35 31 32  |-512 . y(i%)>512|
000008a0  2d 52 43 25 20 8c 0d 04  74 24 20 20 20 e7 20 78  |-RC% ...t$   . x|
000008b0  28 69 25 29 3c 52 43 25  2d 36 34 30 20 80 20 76  |(i%)<RC%-640 . v|
000008c0  78 3c 30 20 76 78 3d 2d  76 78 0d 04 7e 24 20 20  |x<0 vx=-vx..~$  |
000008d0  20 e7 20 78 28 69 25 29  3e 36 34 30 2d 52 43 25  | . x(i%)>640-RC%|
000008e0  20 80 20 76 78 3e 30 20  76 78 3d 2d 76 78 0d 04  | . vx>0 vx=-vx..|
000008f0  88 24 20 20 20 e7 20 79  28 69 25 29 3c 52 43 25  |.$   . y(i%)<RC%|
00000900  2d 35 31 32 20 80 20 76  79 3c 30 20 76 79 3d 2d  |-512 . vy<0 vy=-|
00000910  76 79 0d 04 92 24 20 20  20 e7 20 79 28 69 25 29  |vy...$   . y(i%)|
00000920  3e 35 31 32 2d 52 43 25  20 80 20 76 79 3e 30 20  |>512-RC% . vy>0 |
00000930  76 79 3d 2d 76 79 0d 04  9c 07 20 20 cc 0d 04 a6  |vy=-vy....  ....|
00000940  22 20 20 20 64 3d b6 64  6d 28 69 25 29 3a e7 20  |"   d=.dm(i%):. |
00000950  64 3c 30 2e 30 30 31 20  64 3d 30 2e 30 30 31 0d  |d<0.001 d=0.001.|
00000960  04 b0 10 20 20 20 e7 20  64 3c 52 43 25 20 8c 0d  |...   . d<RC% ..|
00000970  04 ba 1e 20 20 20 20 75  3d 28 78 28 69 6d 25 28  |...    u=(x(im%(|
00000980  69 25 29 29 2d 78 28 69  25 29 29 2f 64 0d 04 c4  |i%))-x(i%))/d...|
00000990  1e 20 20 20 20 76 3d 28  79 28 69 6d 25 28 69 25  |.    v=(y(im%(i%|
000009a0  29 29 2d 79 28 69 25 29  29 2f 64 0d 04 ce 18 20  |))-y(i%))/d.... |
000009b0  20 20 20 73 70 3d 32 2a  28 75 2a 76 78 2b 76 2a  |   sp=2*(u*vx+v*|
000009c0  76 79 29 0d 04 d8 10 20  20 20 20 e7 20 73 70 3e  |vy)....    . sp>|
000009d0  30 20 8c 0d 04 e2 11 20  20 20 20 20 76 78 2d 3d  |0 .....     vx-=|
000009e0  73 70 2a 75 0d 04 ec 11  20 20 20 20 20 76 79 2d  |sp*u....     vy-|
000009f0  3d 73 70 2a 76 0d 04 f6  09 20 20 20 20 cd 0d 05  |=sp*v....    ...|
00000a00  00 08 20 20 20 cc 0d 05  0a 11 20 20 20 20 e7 20  |..   .....    . |
00000a10  64 3c 52 4d 25 20 8c 0d  05 14 1b 20 20 20 20 20  |d<RM% .....     |
00000a20  76 78 3d 61 76 78 28 69  25 29 2f 61 63 25 28 69  |vx=avx(i%)/ac%(i|
00000a30  25 29 0d 05 1e 1b 20 20  20 20 20 76 79 3d 61 76  |%)....     vy=av|
00000a40  79 28 69 25 29 2f 61 63  25 28 69 25 29 0d 05 28  |y(i%)/ac%(i%)..(|
00000a50  09 20 20 20 20 cc 0d 05  32 1e 20 20 20 20 20 61  |.    ...2.     a|
00000a60  78 28 69 25 29 3d 61 78  28 69 25 29 2f 61 63 25  |x(i%)=ax(i%)/ac%|
00000a70  28 69 25 29 0d 05 3c 1e  20 20 20 20 20 61 79 28  |(i%)..<.     ay(|
00000a80  69 25 29 3d 61 79 28 69  25 29 2f 61 63 25 28 69  |i%)=ay(i%)/ac%(i|
00000a90  25 29 0d 05 46 62 20 20  20 20 20 64 63 3d b6 28  |%)..Fb     dc=.(|
00000aa0  20 28 61 78 28 69 25 29  2d 78 28 69 25 29 29 2a  | (ax(i%)-x(i%))*|
00000ab0  28 61 78 28 69 25 29 2d  78 28 69 25 29 29 20 2b  |(ax(i%)-x(i%)) +|
00000ac0  20 28 61 79 28 69 25 29  2d 79 28 69 25 29 29 2a  | (ay(i%)-y(i%))*|
00000ad0  28 61 79 28 69 25 29 2d  79 28 69 25 29 29 20 29  |(ay(i%)-y(i%)) )|
00000ae0  3a e7 20 64 63 3c 30 2e  30 30 31 20 64 63 3d 30  |:. dc<0.001 dc=0|
00000af0  2e 30 30 31 0d 05 50 1c  20 20 20 20 20 61 3d 28  |.001..P.     a=(|
00000b00  61 78 28 69 25 29 2d 78  28 69 25 29 29 2f 64 63  |ax(i%)-x(i%))/dc|
00000b10  0d 05 5a 1c 20 20 20 20  20 62 3d 28 61 79 28 69  |..Z.     b=(ay(i|
00000b20  25 29 2d 79 28 69 25 29  29 2f 64 63 0d 05 64 16  |%)-y(i%))/dc..d.|
00000b30  20 20 20 20 20 76 78 3d  61 2a 47 25 2a 64 2f 52  |     vx=a*G%*d/R|
00000b40  4d 25 0d 05 6e 16 20 20  20 20 20 76 79 3d 62 2a  |M%..n.     vy=b*|
00000b50  47 25 2a 64 2f 52 4d 25  0d 05 78 09 20 20 20 20  |G%*d/RM%..x.    |
00000b60  cd 0d 05 82 08 20 20 20  cd 0d 05 8c 07 20 20 cd  |.....   .....  .|
00000b70  0d 05 96 06 20 cd 0d 05  a0 27 20 66 3d b6 28 76  |.... ....' f=.(v|
00000b80  78 2a 76 78 2b 76 79 2a  76 79 29 3a e7 20 66 3c  |x*vx+vy*vy):. f<|
00000b90  30 2e 30 30 31 20 66 3d  30 2e 30 30 31 0d 05 aa  |0.001 f=0.001...|
00000ba0  10 20 e7 20 66 3c 47 25  2a 47 25 20 8c 0d 05 b4  |. . f<G%*G% ....|
00000bb0  10 20 20 76 78 3d 76 78  2a 47 25 2f 66 0d 05 be  |.  vx=vx*G%/f...|
00000bc0  10 20 20 76 79 3d 76 79  2a 47 25 2f 66 0d 05 c8  |.  vy=vy*G%/f...|
00000bd0  0a 20 20 66 3d 47 25 0d  05 d2 06 20 cd 0d 05 dc  |.  f=G%.... ....|
00000be0  14 20 78 6e 28 69 25 29  3d 78 28 69 25 29 2b 76  |. xn(i%)=x(i%)+v|
00000bf0  78 0d 05 e6 14 20 79 6e  28 69 25 29 3d 79 28 69  |x.... yn(i%)=y(i|
00000c00  25 29 2b 76 79 0d 05 f0  0e 20 76 78 28 69 25 29  |%)+vy.... vx(i%)|
00000c10  3d 76 78 0d 05 fa 0e 20  76 79 28 69 25 29 3d 76  |=vx.... vy(i%)=v|
00000c20  79 0d 06 04 0d 20 6d 76  28 69 25 29 3d 66 0d 06  |y.... mv(i%)=f..|
00000c30  0e 05 ed 0d 06 18 05 3a  0d 06 22 05 e1 0d ff     |.......:.."....|
00000c3f