Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_15_3.adf » !AcornAns_AcornAns » Flocking/Basic/Flock

Flocking/Basic/Flock

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_3.adf » !AcornAns_AcornAns
Filename: Flocking/Basic/Flock
Read OK:
File size: 0E2A bytes
Load address: 0000
Exec address: 0000
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
   10REM Flocking working (at last)
   20:
   30n%=16       :REM number of boids
   40G%=4        :REM 1/scale of arena (try 2 to 8)
   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
  170RL2%=RL%*RL%
  180DIM x(n%-1), y(n%-1)
  190DIM xn(n%-1), yn(n%-1)
  200DIM vx(n%-1), vy(n%-1), mv(n%-1)
  210DIM dm(n%-1), im%(n%-1)
  220DIM ax(n%-1), ay(n%-1)
  230DIM avx(n%-1), avy(n%-1)
  240DIM ac%(n%-1)
  250:
  260MODE 18:OFF:*Pointer
  270ORIGIN 640,512
  280MOUSE ON:mc%=0
  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 WAIT
  430 CLS
  440 FOR i%=0 TO n%-1
  450  LINE x(i%),y(i%),x(i%)+vx(i%)*2*G%/mv(i%),y(i%)+vy(i%)*2*G%/mv(i%)
  460 NEXT
  470 FOR i%=0 TO pn%-1
  480  CIRCLE px(i%),py(i%),pr(i%)
  490 NEXT
  500 PROCmove
  510 PROCmouse
  520 IF INKEY-99 RUN
  530UNTIL 0
  540:
  550END
  560:
  570:
  580DEF PROCmouse
  590MOUSE mx%,my%,mz%
  600IF mz%=1 AND pr(mc%)>1 pr(mc%)-=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
  610IF mz%=2 AND pr(mc%)<100 pr(mc%)+=1:pr2(mc%)=(pr(mc%)+RC%/2)*(pr(mc%)+RC%/2)
  620IF mz%=4 THEN
  630 FOR j%=0 TO pn%-1
  640  IF j%<>mc% THEN
  650   pd=(px(j%)-mx%)*(px(j%)-mx%)+(py(j%)-my%)*(py(j%)-my%)
  660   IF pd<pr2(j%) j%+=&10000
  670  ENDIF
  680 NEXT
  690 IF j%AND&10000 THEN
  700  mc%=j%-&10001:VDU7
  710 ELSE
  720  px(mc%)=mx%:py(mc%)=my%
  730 ENDIF
  740ENDIF
  750ENDPROC
  760:
  770DEF PROCmove
  780:
  790FOR i%=0 TO n%-1
  800 dm(i%)=1E20
  810 ax(i%)=0
  820 ay(i%)=0
  830 avx(i%)=0
  840 avy(i%)=0
  850 ac%(i%)=0
  860NEXT
  870:
  880FOR i%=0 TO n%-2
  890 FOR j%=i%+1 TO n%-1
  900  d = (x(i%)-x(j%))*(x(i%)-x(j%)) + (y(i%)-y(j%))*(y(i%)-y(j%))
  910  IF d<dm(i%) dm(i%)=d:im%(i%)=j%
  920  IF d<dm(j%) dm(j%)=d:im%(j%)=i%
  930  IF d<RL2% THEN
  940   ax(i%)+=x(j%)-x(i%):ay(i%)+=y(j%)-y(i%):avx(i%)+=vx(j%):avy(i%)+=vy(j%):ac%(i%)+=1
  950   ax(j%)+=x(i%)-x(j%):ay(j%)+=y(i%)-y(j%):avx(j%)+=vx(i%):avy(j%)+=vy(i%):ac%(j%)+=1
  960  ENDIF
  970 NEXT
  980NEXT
  990:
 1000FOR i%=0 TO n%-1
 1010 IF ac%(i%)<1 THEN
 1020  ax(i%)+=x(im%(i%))-x(i%):ay(i%)+=y(im%(i%))-y(i%)
 1030  avx(i%)+=vx(im%(i%)):avy(i%)+=vy(im%(i%))
 1040  ac%(i%)+=1
 1050 ENDIF
 1060 vx=vx(i%):vy=vy(i%)
 1070 x=x(i%):y=y(i%)
 1080 FOR j%=0 TO pn%-1
 1090  pd=(px(j%)-x)*(px(j%)-x)+(py(j%)-y)*(py(j%)-y)
 1100  IF pd<pr2(j%) j%+=&10000
 1110 NEXT
 1120 IF j%AND&10000 THEN
 1130  j%-=&10001
 1140  pd=SQRpd:IF pd<0.001 pd=0.001
 1150  u=(px(j%)-x)/pd
 1160  v=(py(j%)-y)/pd
 1170  sp=2*(u*vx+v*vy)
 1180  IF sp>0 THEN
 1190   vx-=sp*u
 1200   vy-=sp*v
 1210  ENDIF
 1220 ELSE
 1230  IF x(i%)<RC%-640 OR x(i%)>640-RC% OR y(i%)<RC%-512 OR y(i%)>512-RC% THEN
 1240   IF x(i%)<RC%-640 AND vx<0 vx=-vx
 1250   IF x(i%)>640-RC% AND vx>0 vx=-vx
 1260   IF y(i%)<RC%-512 AND vy<0 vy=-vy
 1270   IF y(i%)>512-RC% AND vy>0 vy=-vy
 1280  ELSE
 1290   d=SQRdm(i%):IF d<0.001 d=0.001
 1300   IF d<RC% THEN
 1310    u=(x(im%(i%))-x(i%))/d
 1320    v=(y(im%(i%))-y(i%))/d
 1330    sp=2*(u*vx+v*vy)
 1340    IF sp>0 THEN
 1350     vx-=sp*u
 1360     vy-=sp*v
 1370    ENDIF
 1380   ELSE
 1390    ax(i%)=ax(i%)/ac%(i%)
 1400    ay(i%)=ay(i%)/ac%(i%)
 1410    dc=SQR(ax(i%)*ax(i%)+ay(i%)*ay(i%)):IF dc<0.001 dc=0.001
 1420    a=ax(i%)/dc
 1430    b=ay(i%)/dc
 1440    IF d<RM% THEN
 1450     vx=((avx(i%)/ac%(i%))*(RM%-d)+a*G%*(d-RC%))/(RM%-RC%)
 1460     vy=((avy(i%)/ac%(i%))*(RM%-d)+b*G%*(d-RC%))/(RM%-RC%)
 1470    ELSE
 1480     vx=a*G%*d/RM%
 1490     vy=b*G%*d/RM%
 1500    ENDIF
 1510   ENDIF
 1520  ENDIF
 1530 ENDIF
 1540 f=SQR(vx*vx+vy*vy):IF f<0.001 f=0.001
 1550 IF f<G% THEN
 1560  vx=vx*G%/f
 1570  vy=vy*G%/f
 1580  f=G%
 1590 ENDIF
 1600 xn(i%)=x(i%)+vx
 1610 yn(i%)=y(i%)+vy
 1620 vx(i%)=vx
 1630 vy(i%)=vy
 1640 mv(i%)=f
 1650NEXT
 1660:
 1670FOR i%=0 TO n%-1
 1680 x(i%)=xn(i%)
 1690 y(i%)=yn(i%)
 1700NEXT
 1710:
 1720ENDPROC

 � Flocking working (at last)
:
"n%=16       :� number of boids
(0G%=4        :� 1/scale of arena (try 2 to 8)
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:�:*Pointer
ȑ 640,512
ȗ �:mc%=0
":
,
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
��
�:
��
� Ȗ
� �
� � 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
� �mouse

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