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

Flocking/Basic/Old/Flock2

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/Old/Flock2
Read OK:
File size: 0774 bytes
Load address: 0000
Exec address: 0000
File contents

� Not flocking working
:
	n%=16
(G%=4
2:
<%RC%=5*G%    :� collision distance
F-RM%=8*G%    :� velocity matching distance
P!RL%=40*G%   :� local distance
Z:
dRL2%=RL%*RL%
n� x(n%-1), y(n%-1)
x� xn(n%-1), yn(n%-1)
�� vx(n%-1), vy(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%
�v%=G%*2
�� i%=0 � n%-1
� x(i%)=�(p%)-p%/2
 y(i%)=�(p%)-p%/2
 vx(i%)=�(1)*v%
 vy(i%)=�(1)*v%-v%/2
"�
,:
6�
@
 � �-99 �
J Ȗ
T �
^ � i%=0 � n%-1
h  � 69,x(i%),y(i%)
r �
|
 �move
� � i%=0 � n%-1
�  x(i%)=xn(i%)
�  y(i%)=yn(i%)
� �
�� 0
�:
��
�:
�:
�� �move
�:
�� i%=0 � n%-1
� dm(i%)=1E20
 ax(i%)=x(i%)
 ay(i%)=y(i%)
 avx(i%)=vx(i%)
& avy(i%)=vy(i%)
0 ac%(i%)=1
:�
D:
N� i%=0 � n%-2
X � j%=i%+1 � n%-1
bC  d = (x(i%)-x(j%))*(x(i%)-x(j%)) + (y(i%)-y(j%))*(y(i%)-y(j%))
l$  � d<dm(i%) dm(i%)=d:im%(i%)=j%
v$  � 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
� �
  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
*  vx=-u*G%
4  vy=-v*G%
> �
H  � d<RM% �
R   vx=avx(i%)/ac%(i%)
\   vy=avy(i%)/aP:iK� """(i%)/4"��%(9,9,9n%-1)n9�n
+9,�%
�
in

hhhGG9,j%)=8:99(ng x x �1
� �  �  %-1� %)
�%
+%R�i%)=x �  �ololo1
�-9-9-io����vy=avy=av:
pv av av  �:
4���y(i
+
:�:�:ZP: -9-9-0 n%-1)nny(i%))y(i%))yxnxnx�x�v(:�:�:�:e
�9,�%99,�%99*G% x( x( """  d="�2
D�
�
�p%)p%)p
�
�
ststs+=y+=y+(p� �
�yn(6%)>%)>
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 05 3a 0d 00 3c  25 52 43 25 3d 35 2a 47  |..2.:..<%RC%=5*G|
00000040  25 20 20 20 20 3a f4 20  63 6f 6c 6c 69 73 69 6f  |%    :. collisio|
00000050  6e 20 64 69 73 74 61 6e  63 65 0d 00 46 2d 52 4d  |n distance..F-RM|
00000060  25 3d 38 2a 47 25 20 20  20 20 3a f4 20 76 65 6c  |%=8*G%    :. vel|
00000070  6f 63 69 74 79 20 6d 61  74 63 68 69 6e 67 20 64  |ocity matching d|
00000080  69 73 74 61 6e 63 65 0d  00 50 21 52 4c 25 3d 34  |istance..P!RL%=4|
00000090  30 2a 47 25 20 20 20 3a  f4 20 6c 6f 63 61 6c 20  |0*G%   :. local |
000000a0  64 69 73 74 61 6e 63 65  0d 00 5a 05 3a 0d 00 64  |distance..Z.:..d|
000000b0  10 52 4c 32 25 3d 52 4c  25 2a 52 4c 25 0d 00 6e  |.RL2%=RL%*RL%..n|
000000c0  16 de 20 78 28 6e 25 2d  31 29 2c 20 79 28 6e 25  |.. x(n%-1), y(n%|
000000d0  2d 31 29 0d 00 78 18 de  20 78 6e 28 6e 25 2d 31  |-1)..x.. xn(n%-1|
000000e0  29 2c 20 79 6e 28 6e 25  2d 31 29 0d 00 82 18 de  |), yn(n%-1).....|
000000f0  20 76 78 28 6e 25 2d 31  29 2c 20 76 79 28 6e 25  | vx(n%-1), vy(n%|
00000100  2d 31 29 0d 00 8c 19 de  20 64 6d 28 6e 25 2d 31  |-1)..... dm(n%-1|
00000110  29 2c 20 69 6d 25 28 6e  25 2d 31 29 0d 00 96 18  |), im%(n%-1)....|
00000120  de 20 61 78 28 6e 25 2d  31 29 2c 20 61 79 28 6e  |. ax(n%-1), ay(n|
00000130  25 2d 31 29 0d 00 a0 1a  de 20 61 76 78 28 6e 25  |%-1)..... avx(n%|
00000140  2d 31 29 2c 20 61 76 79  28 6e 25 2d 31 29 0d 00  |-1), avy(n%-1)..|
00000150  aa 0f de 20 61 63 25 28  6e 25 2d 31 29 0d 00 b4  |... ac%(n%-1)...|
00000160  05 3a 0d 00 be 0a eb 20  31 38 3a 87 0d 00 c8 0e  |.:..... 18:.....|
00000170  c8 91 20 36 34 30 2c 35  31 32 0d 00 d2 05 3a 0d  |.. 640,512....:.|
00000180  00 dc 0d 70 25 3d 31 32  35 2a 47 25 0d 00 e6 0b  |...p%=125*G%....|
00000190  76 25 3d 47 25 2a 32 0d  00 f0 11 e3 20 69 25 3d  |v%=G%*2..... i%=|
000001a0  30 20 b8 20 6e 25 2d 31  0d 00 fa 15 20 78 28 69  |0 . n%-1.... x(i|
000001b0  25 29 3d b3 28 70 25 29  2d 70 25 2f 32 0d 01 04  |%)=.(p%)-p%/2...|
000001c0  15 20 79 28 69 25 29 3d  b3 28 70 25 29 2d 70 25  |. y(i%)=.(p%)-p%|
000001d0  2f 32 0d 01 0e 13 20 76  78 28 69 25 29 3d b3 28  |/2.... vx(i%)=.(|
000001e0  31 29 2a 76 25 0d 01 18  18 20 76 79 28 69 25 29  |1)*v%.... vy(i%)|
000001f0  3d b3 28 31 29 2a 76 25  2d 76 25 2f 32 0d 01 22  |=.(1)*v%-v%/2.."|
00000200  05 ed 0d 01 2c 05 3a 0d  01 36 05 f5 0d 01 40 0d  |....,.:..6....@.|
00000210  20 e7 20 a6 2d 39 39 20  f9 0d 01 4a 07 20 c8 96  | . .-99 ...J. ..|
00000220  0d 01 54 06 20 db 0d 01  5e 12 20 e3 20 69 25 3d  |..T. ...^. . i%=|
00000230  30 20 b8 20 6e 25 2d 31  0d 01 68 16 20 20 f0 20  |0 . n%-1..h.  . |
00000240  36 39 2c 78 28 69 25 29  2c 79 28 69 25 29 0d 01  |69,x(i%),y(i%)..|
00000250  72 06 20 ed 0d 01 7c 0a  20 f2 6d 6f 76 65 0d 01  |r. ...|. .move..|
00000260  86 12 20 e3 20 69 25 3d  30 20 b8 20 6e 25 2d 31  |.. . i%=0 . n%-1|
00000270  0d 01 90 12 20 20 78 28  69 25 29 3d 78 6e 28 69  |....  x(i%)=xn(i|
00000280  25 29 0d 01 9a 12 20 20  79 28 69 25 29 3d 79 6e  |%)....  y(i%)=yn|
00000290  28 69 25 29 0d 01 a4 06  20 ed 0d 01 ae 07 fd 20  |(i%).... ...... |
000002a0  30 0d 01 b8 05 3a 0d 01  c2 05 e0 0d 01 cc 05 3a  |0....:.........:|
000002b0  0d 01 d6 05 3a 0d 01 e0  0b dd 20 f2 6d 6f 76 65  |....:..... .move|
000002c0  0d 01 ea 05 3a 0d 01 f4  11 e3 20 69 25 3d 30 20  |....:..... i%=0 |
000002d0  b8 20 6e 25 2d 31 0d 01  fe 10 20 64 6d 28 69 25  |. n%-1.... dm(i%|
000002e0  29 3d 31 45 32 30 0d 02  08 11 20 61 78 28 69 25  |)=1E20.... ax(i%|
000002f0  29 3d 78 28 69 25 29 0d  02 12 11 20 61 79 28 69  |)=x(i%).... ay(i|
00000300  25 29 3d 79 28 69 25 29  0d 02 1c 13 20 61 76 78  |%)=y(i%).... avx|
00000310  28 69 25 29 3d 76 78 28  69 25 29 0d 02 26 13 20  |(i%)=vx(i%)..&. |
00000320  61 76 79 28 69 25 29 3d  76 79 28 69 25 29 0d 02  |avy(i%)=vy(i%)..|
00000330  30 0e 20 61 63 25 28 69  25 29 3d 31 0d 02 3a 05  |0. ac%(i%)=1..:.|
00000340  ed 0d 02 44 05 3a 0d 02  4e 11 e3 20 69 25 3d 30  |...D.:..N.. i%=0|
00000350  20 b8 20 6e 25 2d 32 0d  02 58 15 20 e3 20 6a 25  | . n%-2..X. . j%|
00000360  3d 69 25 2b 31 20 b8 20  6e 25 2d 31 0d 02 62 43  |=i%+1 . n%-1..bC|
00000370  20 20 64 20 3d 20 28 78  28 69 25 29 2d 78 28 6a  |  d = (x(i%)-x(j|
00000380  25 29 29 2a 28 78 28 69  25 29 2d 78 28 6a 25 29  |%))*(x(i%)-x(j%)|
00000390  29 20 2b 20 28 79 28 69  25 29 2d 79 28 6a 25 29  |) + (y(i%)-y(j%)|
000003a0  29 2a 28 79 28 69 25 29  2d 79 28 6a 25 29 29 0d  |)*(y(i%)-y(j%)).|
000003b0  02 6c 24 20 20 e7 20 64  3c 64 6d 28 69 25 29 20  |.l$  . d<dm(i%) |
000003c0  64 6d 28 69 25 29 3d 64  3a 69 6d 25 28 69 25 29  |dm(i%)=d:im%(i%)|
000003d0  3d 6a 25 0d 02 76 24 20  20 e7 20 64 3c 64 6d 28  |=j%..v$  . d<dm(|
000003e0  6a 25 29 20 64 6d 28 6a  25 29 3d 64 3a 69 6d 25  |j%) dm(j%)=d:im%|
000003f0  28 6a 25 29 3d 69 25 0d  02 80 10 20 20 e7 20 64  |(j%)=i%....  . d|
00000400  3c 52 4c 32 25 20 8c 0d  02 8a 4d 20 20 20 61 78  |<RL2% ....M   ax|
00000410  28 69 25 29 2b 3d 78 28  6a 25 29 3a 61 79 28 69  |(i%)+=x(j%):ay(i|
00000420  25 29 2b 3d 79 28 6a 25  29 3a 61 76 78 28 69 25  |%)+=y(j%):avx(i%|
00000430  29 2b 3d 76 78 28 6a 25  29 3a 61 76 79 28 69 25  |)+=vx(j%):avy(i%|
00000440  29 2b 3d 76 79 28 6a 25  29 3a 61 63 25 28 69 25  |)+=vy(j%):ac%(i%|
00000450  29 2b 3d 31 0d 02 94 4d  20 20 20 61 78 28 6a 25  |)+=1...M   ax(j%|
00000460  29 2b 3d 78 28 69 25 29  3a 61 79 28 6a 25 29 2b  |)+=x(i%):ay(j%)+|
00000470  3d 79 28 69 25 29 3a 61  76 78 28 6a 25 29 2b 3d  |=y(i%):avx(j%)+=|
00000480  76 78 28 69 25 29 3a 61  76 79 28 6a 25 29 2b 3d  |vx(i%):avy(j%)+=|
00000490  76 79 28 69 25 29 3a 61  63 25 28 6a 25 29 2b 3d  |vy(i%):ac%(j%)+=|
000004a0  31 0d 02 9e 07 20 20 cd  0d 02 a8 06 20 ed 0d 02  |1....  ..... ...|
000004b0  b2 05 ed 0d 02 bc 05 3a  0d 02 c6 11 e3 20 69 25  |.......:..... i%|
000004c0  3d 30 20 b8 20 6e 25 2d  31 0d 02 d0 15 20 e7 20  |=0 . n%-1.... . |
000004d0  64 6d 28 69 25 29 3e 3d  52 4c 32 25 20 8c 0d 02  |dm(i%)>=RL2% ...|
000004e0  da 2b 20 20 61 78 28 69  25 29 2b 3d 78 28 69 6d  |.+  ax(i%)+=x(im|
000004f0  25 28 69 25 29 29 3a 61  79 28 69 25 29 2b 3d 79  |%(i%)):ay(i%)+=y|
00000500  28 69 6d 25 28 69 25 29  29 0d 02 e4 2f 20 20 61  |(im%(i%)).../  a|
00000510  76 78 28 69 25 29 2b 3d  76 78 28 69 6d 25 28 69  |vx(i%)+=vx(im%(i|
00000520  25 29 29 3a 61 76 79 28  69 25 29 2b 3d 76 79 28  |%)):avy(i%)+=vy(|
00000530  69 6d 25 28 69 25 29 29  0d 02 ee 10 20 20 61 63  |im%(i%))....  ac|
00000540  25 28 69 25 29 2b 3d 31  0d 02 f8 06 20 cd 0d 03  |%(i%)+=1.... ...|
00000550  02 20 20 64 3d b6 64 6d  28 69 25 29 3a e7 20 64  |.  d=.dm(i%):. d|
00000560  3c 30 2e 30 30 31 20 64  3d 30 2e 30 30 31 0d 03  |<0.001 d=0.001..|
00000570  0c 0e 20 e7 20 64 3c 52  43 25 20 8c 0d 03 16 1c  |.. . d<RC% .....|
00000580  20 20 75 3d 28 78 28 69  6d 25 28 69 25 29 29 2d  |  u=(x(im%(i%))-|
00000590  78 28 69 25 29 29 2f 64  0d 03 20 1c 20 20 76 3d  |x(i%))/d.. .  v=|
000005a0  28 79 28 69 6d 25 28 69  25 29 29 2d 79 28 69 25  |(y(im%(i%))-y(i%|
000005b0  29 29 2f 64 0d 03 2a 0e  20 20 76 78 3d 2d 75 2a  |))/d..*.  vx=-u*|
000005c0  47 25 0d 03 34 0e 20 20  76 79 3d 2d 76 2a 47 25  |G%..4.  vy=-v*G%|
000005d0  0d 03 3e 06 20 cc 0d 03  48 0f 20 20 e7 20 64 3c  |..>. ...H.  . d<|
000005e0  52 4d 25 20 8c 0d 03 52  19 20 20 20 76 78 3d 61  |RM% ...R.   vx=a|
000005f0  76 78 28 69 25 29 2f 61  63 25 28 69 25 29 0d 03  |vx(i%)/ac%(i%)..|
00000600  5c 19 20 20 20 76 79 3d  61 76 79 28 69 25 29 2f  |\.   vy=avy(i%)/|
00000610  61 00 50 3a 69 4b f4 20  22 22 22 28 69 25 29 2f  |a.P:iK. """(i%)/|
00000620  34 22 ac ac 25 28 39 2c  39 2c 39 6e 25 2d 31 29  |4"..%(9,9,9n%-1)|
00000630  6e 39 06 86 6e 0d 02 2b  06 39 2c 80 25 0d ed 0d  |n9..n..+.9,.%...|
00000640  01 69 6e 00 0a 00 0a 00  68 68 68 08 47 08 47 08  |.in.....hhh.G.G.|
00000650  39 2c 6a 25 29 3d 38 3a  39 39 28 6e 67 20 78 20  |9,j%)=8:99(ng x |
00000660  78 20 86 31 0d 02 f8 20  b8 20 20 b8 20 20 25 2d  |x .1... .  .  %-|
00000670  31 de 20 25 29 0d d0 25  0d 02 2b 25 03 52 82 11  |1. %)..%..+%.R..|
00000680  69 25 29 3d 78 20 e7 20  20 f2 6f 6c 6f 6c 6f 31  |i%)=x .  .ololo1|
00000690  0d 02 f8 2d 39 2d 39 2d  02 12 69 6f 88 88 88 07  |...-9-9-..io....|
000006a0  fd 76 79 3d 61 76 79 3d  61 76 05 3a 0d 00 03 70  |.vy=avy=av.:...p|
000006b0  76 13 20 61 76 13 20 61  76 13 0e 20 20 05 aa 00  |v. av. av..  ...|
000006c0  13 00 00 01 0e 05 3a 0d  34 0e 88 88 88 79 28 69  |......:.4....y(i|
000006d0  0d 02 2b 0d 3a 87 3a 87  3a 5a 05 50 3a 11 20 2d  |..+.:.:.:Z.P:. -|
000006e0  39 2d 39 2d 30 20 6e 25  2d 31 29 6e 6e 79 28 69  |9-9-0 n%-1)nny(i|
000006f0  25 29 29 79 28 69 25 29  29 79 78 6e 78 6e 78 06  |%))y(i%))yxnxnx.|
00000700  9a 06 06 78 07 fd 76 28  06 3a 87 3a 87 3a 00 00  |...x..v(.:.:.:..|
00000710  01 b6 3a 65 0d 00 a1 39  2c 80 25 39 39 2c 80 25  |..:e...9,.%99,.%|
00000720  39 39 2a 47 25 20 78 28  20 78 28 20 22 05 22 05  |99*G% x( x( ".".|
00000730  22 20 20 64 3d 03 22 08  11 08 11 08 96 32 0d 00  |"  d=."......2..|
00000740  44 96 0d 96 0d 96 70 25  29 70 25 29 70 0d 01 a4  |D.....p%)p%)p...|
00000750  0d 01 a4 0d 73 74 73 74  73 2b 3d 79 2b 3d 79 2b  |....ststs+=y+=y+|
00000760  28 70 e6 0b 06 20 ed 0d  d1 79 6e 28 01 36 25 29  |(p... ...yn(.6%)|
00000770  3e 25 29 3e                                       |>%)>|
00000774