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

Flocking/Basic/Old/Flock5

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/Flock5
Read OK:
File size: 0DC8 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM Flocking working (kinda)
   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
  290MOUSE ON:mc%=0
  300:
  310p%=125*G%
  320v%=G%*4
  330FOR i%=0 TO n%-1
  340 x(i%)=RND(p%)-p%/2
  350 y(i%)=RND(p%)-p%/2
  360 vx(i%)=RND(1)*v%
  370 vy(i%)=RND(1)*v%-v%/2
  380 f=SQR(vx(i%)*vx(i%)+vy(i%)*vy(i%)):IF f<0.001 f=0.001
  390 mv(i%)=f
  400NEXT
  410:
  420REPEAT
  430 IF INKEY-99 RUN
  440 WAIT
  450 CLS
  460 FOR i%=0 TO n%-1
  470  LINE x(i%),y(i%),x(i%)+vx(i%)*2*G%/mv(i%),y(i%)+vy(i%)*2*G%/mv(i%)
  480 NEXT
  490 FOR i%=0 TO pn%-1
  500  CIRCLE px(i%),py(i%),pr(i%)
  510 NEXT
  520 PROCmove
  530 FOR i%=0 TO n%-1
  540  x(i%)=xn(i%)
  550  y(i%)=yn(i%)
  560 NEXT
  570 MOUSE mx%,my%,mz%
  580 IF mz%=1 AND pr(mc%)>1 pr(mc%)-=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
  590 IF mz%=2 AND pr(mc%)<100 pr(mc%)+=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
  600 IF mz%=4 THEN
  610  FOR j%=0 TO pn%-1
  620   pd=(px(j%)-mx%)*(px(j%)-mx%)+(py(j%)-my%)*(py(j%)-my%)
  630   IF pd<pr2(j%) j%+=&10000
  640  NEXT
  650  IF j%AND&10000 THEN
  660   mc%=j%-&10001:VDU7
  670  ELSE
  680   px(mc%)=mx%:py(mc%)=my%
  690  ENDIF
  700 ENDIF
  710UNTIL 0
  720:
  730END
  740:
  750:
  760DEF PROCmove
  770:
  780FOR i%=0 TO n%-1
  790 dm(i%)=1E20
  800 ax(i%)=0
  810 ay(i%)=0
  820 avx(i%)=0
  830 avy(i%)=0
  840 ac%(i%)=0
  850NEXT
  860:
  870FOR i%=0 TO n%-2
  880 FOR j%=i%+1 TO n%-1
  890  d = (x(i%)-x(j%))*(x(i%)-x(j%)) + (y(i%)-y(j%))*(y(i%)-y(j%))
  900  IF d<dm(i%) dm(i%)=d:im%(i%)=j%
  910  IF d<dm(j%) dm(j%)=d:im%(j%)=i%
  920  IF d<RL2% THEN
  930   ax(i%)+=x(j%):ay(i%)+=y(j%):avx(i%)+=vx(j%):avy(i%)+=vy(j%):ac%(i%)+=1
  940   ax(j%)+=x(i%):ay(j%)+=y(i%):avx(j%)+=vx(i%):avy(j%)+=vy(i%):ac%(j%)+=1
  950  ENDIF
  960 NEXT
  970NEXT
  980:
  990FOR i%=0 TO n%-1
 1000 IF dm(i%)>=RL2% THEN
 1010  ax(i%)+=x(im%(i%)):ay(i%)+=y(im%(i%))
 1020  avx(i%)+=vx(im%(i%)):avy(i%)+=vy(im%(i%))
 1030  ac%(i%)+=1
 1040 ENDIF
 1050 vx=vx(i%):vy=vy(i%)
 1060 x=x(i%):y=y(i%)
 1070 FOR j%=0 TO pn%-1
 1080  pd=(px(j%)-x)*(px(j%)-x)+(py(j%)-y)*(py(j%)-y)
 1090  IF pd<pr2(j%) j%+=&10000
 1100 NEXT
 1110 IF j%AND&10000 THEN
 1120  j%-=&10001
 1130  pd=SQRpd:IF pd<0.001 pd=0.001
 1140  u=(px(j%)-x)/pd
 1150  v=(py(j%)-y)/pd
 1160  sp=2*(u*vx+v*vy)
 1170  IF sp>0 THEN
 1180   vx-=sp*u
 1190   vy-=sp*v
 1200  ENDIF
 1210 ELSE
 1220  IF x(i%)<RC%-640 OR x(i%)>640-RC% OR y(i%)<RC%-512 OR y(i%)>512-RC% THEN
 1230   IF x(i%)<RC%-640 AND vx<0 vx=-vx
 1240   IF x(i%)>640-RC% AND vx>0 vx=-vx
 1250   IF y(i%)<RC%-512 AND vy<0 vy=-vy
 1260   IF y(i%)>512-RC% AND vy>0 vy=-vy
 1270  ELSE
 1280   d=SQRdm(i%):IF d<0.001 d=0.001
 1290   IF d<RC% THEN
 1300    u=(x(im%(i%))-x(i%))/d
 1310    v=(y(im%(i%))-y(i%))/d
 1320    sp=2*(u*vx+v*vy)
 1330    IF sp>0 THEN
 1340     vx-=sp*u
 1350     vy-=sp*v
 1360    ENDIF
 1370   ELSE
 1380    ax(i%)=ax(i%)/ac%(i%)
 1390    ay(i%)=ay(i%)/ac%(i%)
 1400    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
 1410    a=(ax(i%)-x(i%))/dc
 1420    b=(ay(i%)-y(i%))/dc
 1430    IF d<RM% THEN
 1440     vx=((avx(i%)/ac%(i%))*(RM%-d)+a*G%*(d-RC%))/(RM%-RC%)
 1450     vy=((avy(i%)/ac%(i%))*(RM%-d)+b*G%*(d-RC%))/(RM%-RC%)
 1460    ELSE
 1470     vx=a*G%*d/RM%
 1480     vy=b*G%*d/RM%
 1490    ENDIF
 1500   ENDIF
 1510  ENDIF
 1520 ENDIF
 1530 f=SQR(vx*vx+vy*vy):IF f<0.001 f=0.001
 1540 IF f<G% THEN
 1550  vx=vx*G%/f
 1560  vy=vy*G%/f
 1570  f=G%
 1580 ENDIF
 1590 xn(i%)=x(i%)+vx
 1600 yn(i%)=y(i%)+vy
 1610 vx(i%)=vx
 1620 vy(i%)=vy
 1630 mv(i%)=f
 1640NEXT
 1650:
 1660ENDPROC

� Flocking working (kinda)
:
	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
"ȗ �:mc%=0
,:
6
p%=125*G%
@v%=G%*4
J� i%=0 � n%-1
T x(i%)=�(p%)-p%/2
^ y(i%)=�(p%)-p%/2
h vx(i%)=�(1)*v%
r vy(i%)=�(1)*v%-v%/2
|7 f=�(vx(i%)*vx(i%)+vy(i%)*vy(i%)):� f<0.001 f=0.001
�
 mv(i%)=f
��
�:
��
�
 � �-99 �
� Ȗ
� �
� � i%=0 � n%-1
�E  � x(i%),y(i%),x(i%)+vx(i%)*2*G%/mv(i%),y(i%)+vy(i%)*2*G%/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 �
: ȗ mx%,my%,mz%
DL � mz%=1 � pr(mc%)>1 pr(mc%)-=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
NN � mz%=2 � pr(mc%)<100 pr(mc%)+=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
X � mz%=4 �
b  � j%=0 � pn%-1
l=   pd=(px(j%)-mx%)*(px(j%)-mx%)+(py(j%)-my%)*(py(j%)-my%)
v   � pd<pr2(j%) j%+=&10000
�  �
�  � j%�&10000 �
�   mc%=j%-&10001:�7
�  �
�   px(mc%)=mx%:py(mc%)=my%
�  �
� �
�� 0
�:
��
�:
�:
�� �move
:
� i%=0 � n%-1
 dm(i%)=1E20
 
 ax(i%)=0
*
 ay(i%)=0
4 avx(i%)=0
> avy(i%)=0
H ac%(i%)=0
R�
\:
f� i%=0 � n%-2
p � j%=i%+1 � n%-1
zC  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%
�  � d<RL2% �
�M   ax(i%)+=x(j%):ay(i%)+=y(j%):avx(i%)+=vx(j%):avy(i%)+=vy(j%):ac%(i%)+=1
�M   ax(j%)+=x(i%):ay(j%)+=y(i%):avx(j%)+=vx(i%):avy(j%)+=vy(i%):ac%(j%)+=1
�  �
� �
��
�:
�� 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
84  pd=(px(j%)-x)*(px(j%)-x)+(py(j%)-y)*(py(j%)-y)
B  � pd<pr2(j%) j%+=&10000
L �
V � j%�&10000 �
`  j%-=&10001
j   pd=�pd:� pd<0.001 pd=0.001
t  u=(px(j%)-x)/pd
~  v=(py(j%)-y)/pd
�  sp=2*(u*vx+v*vy)
�  � sp>0 �
�   vx-=sp*u
�   vy-=sp*v
�  �
� �
�G  � x(i%)<RC%-640 � x(i%)>640-RC% � y(i%)<RC%-512 � y(i%)>512-RC% �
�$   � 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)
2    � sp>0 �
<     vx-=sp*u
F     vy-=sp*v
P	    �
Z   �
d    ax(i%)=ax(i%)/ac%(i%)
n    ay(i%)=ay(i%)/ac%(i%)
xa    dc=�( (ax(i%)-x(i%))*(ax(i%)-x(i%)) + (ay(i%)-y(i%))*(ay(i%)-y(i%)) ):� dc<0.001 dc=0.001
�    a=(ax(i%)-x(i%))/dc
�    b=(ay(i%)-y(i%))/dc
�    � d<RM% �
�>     vx=((avx(i%)/ac%(i%))*(RM%-d)+a*G%*(d-RC%))/(RM%-RC%)
�>     vy=((avy(i%)/ac%(i%))*(RM%-d)+b*G%*(d-RC%))/(RM%-RC%)
�	    �
�     vx=a*G%*d/RM%
�     vy=b*G%*d/RM%
�	    �
�   �
�  �
� �
�' f=�(vx*vx+vy*vy):� f<0.001 f=0.001

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