Home » Archimedes archive » Acorn User » AU 1993-06.adf » !StarInfo_StarInfo » Challenge/Procs/Best

Challenge/Procs/Best

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 » Archimedes archive » Acorn User » AU 1993-06.adf » !StarInfo_StarInfo
Filename: Challenge/Procs/Best
Read OK:
File size: 050F bytes
Load address: 0000
Exec address: 0000
File contents
   10REM     >Best (Info19)
   20REM By  Dave Acton
   30REM For 32-bit machines
   40REM (c) BAU June 1993
   50:
   60DEF FNbest(board%,player%,turn%,size%,first%,left%)
   70LOCAL best_score%,c%(),t%(),x%,y%,xx%,yy%,b%(),try_x%,try_y%
   80IF turn%=-1 DIM best_brd%(size%+1,size%+1),best_brd2%(size%+1,size%+1):=0
   90DIM c%(2),t%(2),b%(size%,size%)
  100FOR x%=0 TO size%+1
  110 FOR y%=0 TO size%+1
  120  best_brd%(x%,y%)=board%?((x%+size%-1) MOD size%+size%*((y%+size%-1) MOD size%))
  130 NEXT
  140NEXT
  150best_score%=-9999
  160b%()=-10000
  170FOR try_x%=1 TO size%
  180 FOR try_y%=1 TO size%
  190  IF best_brd%(try_x%,try_y%)=0 THEN
  200   best_brd2%()=best_brd%()
  210   t%()=0
  220   best_brd2%(try_x%,try_y%)=player%
  230   FOR x%=1 TO size%
  240    FOR y%=1 TO size%
  250     c%()=0
  260     FOR xx%=-1 TO 1
  270      FOR yy%=-1 TO 1
  280       c%(best_brd2%(x%+xx%,y%+yy%))+=1
  290      NEXT
  300     NEXT
  310     c%(best_brd2%(x%,y%))-=1
  320     IF best_brd2%(x%,y%)=0 THEN
  330      IF c%(1)+c%(2)=3 THEN
  340       IF c%(1)>c%(2) THEN t%(1)+=1 ELSE t%(2)+=1
  350      ENDIF
  360     ELSE
  370      IF c%(1)+c%(2)=2 OR c%(1)+c%(2)=3 THEN t%(best_brd2%(x%,y%))+=1
  380     ENDIF
  390    NEXT
  400   NEXT
  410   b%(try_x%,try_y%)=t%(player%)-t%(3-player%)
  420   IF b%(try_x%,try_y%)>best_score% best_score%=b%(try_x%,try_y%)
  430  ENDIF
  440 NEXT
  450NEXT
  460REPEAT
  470 x%=RND(size%)
  480 y%=RND(size%)
  490UNTIL b%(x%,y%)=best_score%
  500=(x%-1)+size%*(y%-1)

�     >Best (Info19)
� By  Dave Acton
� For 32-bit machines
(� (c) BAU June 1993
2:
<4� �best(board%,player%,turn%,size%,first%,left%)
F<� best_score%,c%(),t%(),x%,y%,xx%,yy%,b%(),try_x%,try_y%
PJ� turn%=-1 � best_brd%(size%+1,size%+1),best_brd2%(size%+1,size%+1):=0
Z!� c%(2),t%(2),b%(size%,size%)
d� x%=0 � size%+1
n � y%=0 � size%+1
xQ  best_brd%(x%,y%)=board%?((x%+size%-1) � size%+size%*((y%+size%-1) � size%))
� �
��
�best_score%=-9999
�b%()=-10000
�� try_x%=1 � size%
� � try_y%=1 � size%
�$  � best_brd%(try_x%,try_y%)=0 �
�   best_brd2%()=best_brd%()
�
   t%()=0
�(   best_brd2%(try_x%,try_y%)=player%
�   � x%=1 � size%
�    � y%=1 � size%
�     c%()=0
     � xx%=-1 � 1
      � yy%=-1 � 1
+       c%(best_brd2%(x%+xx%,y%+yy%))+=1
"      �
,
     �
6!     c%(best_brd2%(x%,y%))-=1
@      � best_brd2%(x%,y%)=0 �
J      � c%(1)+c%(2)=3 �
T.       � c%(1)>c%(2) � t%(1)+=1 � t%(2)+=1
^      �
h
     �
rD      � c%(1)+c%(2)=2 � c%(1)+c%(2)=3 � t%(best_brd2%(x%,y%))+=1
|
     �
�	    �
�   �
�2   b%(try_x%,try_y%)=t%(player%)-t%(3-player%)
�D   � b%(try_x%,try_y%)>best_score% best_score%=b%(try_x%,try_y%)
�  �
� �
��
��
� x%=�(size%)
� y%=�(size%)
�� b%(x%,y%)=best_score%
�=(x%-1)+size%*(y%-1)
�
00000000  0d 00 0a 18 f4 20 20 20  20 20 3e 42 65 73 74 20  |.....     >Best |
00000010  28 49 6e 66 6f 31 39 29  0d 00 14 14 f4 20 42 79  |(Info19)..... By|
00000020  20 20 44 61 76 65 20 41  63 74 6f 6e 0d 00 1e 19  |  Dave Acton....|
00000030  f4 20 46 6f 72 20 33 32  2d 62 69 74 20 6d 61 63  |. For 32-bit mac|
00000040  68 69 6e 65 73 0d 00 28  17 f4 20 28 63 29 20 42  |hines..(.. (c) B|
00000050  41 55 20 4a 75 6e 65 20  31 39 39 33 0d 00 32 05  |AU June 1993..2.|
00000060  3a 0d 00 3c 34 dd 20 a4  62 65 73 74 28 62 6f 61  |:..<4. .best(boa|
00000070  72 64 25 2c 70 6c 61 79  65 72 25 2c 74 75 72 6e  |rd%,player%,turn|
00000080  25 2c 73 69 7a 65 25 2c  66 69 72 73 74 25 2c 6c  |%,size%,first%,l|
00000090  65 66 74 25 29 0d 00 46  3c ea 20 62 65 73 74 5f  |eft%)..F<. best_|
000000a0  73 63 6f 72 65 25 2c 63  25 28 29 2c 74 25 28 29  |score%,c%(),t%()|
000000b0  2c 78 25 2c 79 25 2c 78  78 25 2c 79 79 25 2c 62  |,x%,y%,xx%,yy%,b|
000000c0  25 28 29 2c 74 72 79 5f  78 25 2c 74 72 79 5f 79  |%(),try_x%,try_y|
000000d0  25 0d 00 50 4a e7 20 74  75 72 6e 25 3d 2d 31 20  |%..PJ. turn%=-1 |
000000e0  de 20 62 65 73 74 5f 62  72 64 25 28 73 69 7a 65  |. best_brd%(size|
000000f0  25 2b 31 2c 73 69 7a 65  25 2b 31 29 2c 62 65 73  |%+1,size%+1),bes|
00000100  74 5f 62 72 64 32 25 28  73 69 7a 65 25 2b 31 2c  |t_brd2%(size%+1,|
00000110  73 69 7a 65 25 2b 31 29  3a 3d 30 0d 00 5a 21 de  |size%+1):=0..Z!.|
00000120  20 63 25 28 32 29 2c 74  25 28 32 29 2c 62 25 28  | c%(2),t%(2),b%(|
00000130  73 69 7a 65 25 2c 73 69  7a 65 25 29 0d 00 64 14  |size%,size%)..d.|
00000140  e3 20 78 25 3d 30 20 b8  20 73 69 7a 65 25 2b 31  |. x%=0 . size%+1|
00000150  0d 00 6e 15 20 e3 20 79  25 3d 30 20 b8 20 73 69  |..n. . y%=0 . si|
00000160  7a 65 25 2b 31 0d 00 78  51 20 20 62 65 73 74 5f  |ze%+1..xQ  best_|
00000170  62 72 64 25 28 78 25 2c  79 25 29 3d 62 6f 61 72  |brd%(x%,y%)=boar|
00000180  64 25 3f 28 28 78 25 2b  73 69 7a 65 25 2d 31 29  |d%?((x%+size%-1)|
00000190  20 83 20 73 69 7a 65 25  2b 73 69 7a 65 25 2a 28  | . size%+size%*(|
000001a0  28 79 25 2b 73 69 7a 65  25 2d 31 29 20 83 20 73  |(y%+size%-1) . s|
000001b0  69 7a 65 25 29 29 0d 00  82 06 20 ed 0d 00 8c 05  |ize%)).... .....|
000001c0  ed 0d 00 96 15 62 65 73  74 5f 73 63 6f 72 65 25  |.....best_score%|
000001d0  3d 2d 39 39 39 39 0d 00  a0 0f 62 25 28 29 3d 2d  |=-9999....b%()=-|
000001e0  31 30 30 30 30 0d 00 aa  16 e3 20 74 72 79 5f 78  |10000..... try_x|
000001f0  25 3d 31 20 b8 20 73 69  7a 65 25 0d 00 b4 17 20  |%=1 . size%.... |
00000200  e3 20 74 72 79 5f 79 25  3d 31 20 b8 20 73 69 7a  |. try_y%=1 . siz|
00000210  65 25 0d 00 be 24 20 20  e7 20 62 65 73 74 5f 62  |e%...$  . best_b|
00000220  72 64 25 28 74 72 79 5f  78 25 2c 74 72 79 5f 79  |rd%(try_x%,try_y|
00000230  25 29 3d 30 20 8c 0d 00  c8 1f 20 20 20 62 65 73  |%)=0 .....   bes|
00000240  74 5f 62 72 64 32 25 28  29 3d 62 65 73 74 5f 62  |t_brd2%()=best_b|
00000250  72 64 25 28 29 0d 00 d2  0d 20 20 20 74 25 28 29  |rd%()....   t%()|
00000260  3d 30 0d 00 dc 28 20 20  20 62 65 73 74 5f 62 72  |=0...(   best_br|
00000270  64 32 25 28 74 72 79 5f  78 25 2c 74 72 79 5f 79  |d2%(try_x%,try_y|
00000280  25 29 3d 70 6c 61 79 65  72 25 0d 00 e6 15 20 20  |%)=player%....  |
00000290  20 e3 20 78 25 3d 31 20  b8 20 73 69 7a 65 25 0d  | . x%=1 . size%.|
000002a0  00 f0 16 20 20 20 20 e3  20 79 25 3d 31 20 b8 20  |...    . y%=1 . |
000002b0  73 69 7a 65 25 0d 00 fa  0f 20 20 20 20 20 63 25  |size%....     c%|
000002c0  28 29 3d 30 0d 01 04 15  20 20 20 20 20 e3 20 78  |()=0....     . x|
000002d0  78 25 3d 2d 31 20 b8 20  31 0d 01 0e 16 20 20 20  |x%=-1 . 1....   |
000002e0  20 20 20 e3 20 79 79 25  3d 2d 31 20 b8 20 31 0d  |   . yy%=-1 . 1.|
000002f0  01 18 2b 20 20 20 20 20  20 20 63 25 28 62 65 73  |..+       c%(bes|
00000300  74 5f 62 72 64 32 25 28  78 25 2b 78 78 25 2c 79  |t_brd2%(x%+xx%,y|
00000310  25 2b 79 79 25 29 29 2b  3d 31 0d 01 22 0b 20 20  |%+yy%))+=1..".  |
00000320  20 20 20 20 ed 0d 01 2c  0a 20 20 20 20 20 ed 0d  |    ...,.     ..|
00000330  01 36 21 20 20 20 20 20  63 25 28 62 65 73 74 5f  |.6!     c%(best_|
00000340  62 72 64 32 25 28 78 25  2c 79 25 29 29 2d 3d 31  |brd2%(x%,y%))-=1|
00000350  0d 01 40 20 20 20 20 20  20 e7 20 62 65 73 74 5f  |..@      . best_|
00000360  62 72 64 32 25 28 78 25  2c 79 25 29 3d 30 20 8c  |brd2%(x%,y%)=0 .|
00000370  0d 01 4a 1b 20 20 20 20  20 20 e7 20 63 25 28 31  |..J.      . c%(1|
00000380  29 2b 63 25 28 32 29 3d  33 20 8c 0d 01 54 2e 20  |)+c%(2)=3 ...T. |
00000390  20 20 20 20 20 20 e7 20  63 25 28 31 29 3e 63 25  |      . c%(1)>c%|
000003a0  28 32 29 20 8c 20 74 25  28 31 29 2b 3d 31 20 8b  |(2) . t%(1)+=1 .|
000003b0  20 74 25 28 32 29 2b 3d  31 0d 01 5e 0b 20 20 20  | t%(2)+=1..^.   |
000003c0  20 20 20 cd 0d 01 68 0a  20 20 20 20 20 cc 0d 01  |   ...h.     ...|
000003d0  72 44 20 20 20 20 20 20  e7 20 63 25 28 31 29 2b  |rD      . c%(1)+|
000003e0  63 25 28 32 29 3d 32 20  84 20 63 25 28 31 29 2b  |c%(2)=2 . c%(1)+|
000003f0  63 25 28 32 29 3d 33 20  8c 20 74 25 28 62 65 73  |c%(2)=3 . t%(bes|
00000400  74 5f 62 72 64 32 25 28  78 25 2c 79 25 29 29 2b  |t_brd2%(x%,y%))+|
00000410  3d 31 0d 01 7c 0a 20 20  20 20 20 cd 0d 01 86 09  |=1..|.     .....|
00000420  20 20 20 20 ed 0d 01 90  08 20 20 20 ed 0d 01 9a  |    .....   ....|
00000430  32 20 20 20 62 25 28 74  72 79 5f 78 25 2c 74 72  |2   b%(try_x%,tr|
00000440  79 5f 79 25 29 3d 74 25  28 70 6c 61 79 65 72 25  |y_y%)=t%(player%|
00000450  29 2d 74 25 28 33 2d 70  6c 61 79 65 72 25 29 0d  |)-t%(3-player%).|
00000460  01 a4 44 20 20 20 e7 20  62 25 28 74 72 79 5f 78  |..D   . b%(try_x|
00000470  25 2c 74 72 79 5f 79 25  29 3e 62 65 73 74 5f 73  |%,try_y%)>best_s|
00000480  63 6f 72 65 25 20 62 65  73 74 5f 73 63 6f 72 65  |core% best_score|
00000490  25 3d 62 25 28 74 72 79  5f 78 25 2c 74 72 79 5f  |%=b%(try_x%,try_|
000004a0  79 25 29 0d 01 ae 07 20  20 cd 0d 01 b8 06 20 ed  |y%)....  ..... .|
000004b0  0d 01 c2 05 ed 0d 01 cc  05 f5 0d 01 d6 10 20 78  |.............. x|
000004c0  25 3d b3 28 73 69 7a 65  25 29 0d 01 e0 10 20 79  |%=.(size%).... y|
000004d0  25 3d b3 28 73 69 7a 65  25 29 0d 01 ea 1b fd 20  |%=.(size%)..... |
000004e0  62 25 28 78 25 2c 79 25  29 3d 62 65 73 74 5f 73  |b%(x%,y%)=best_s|
000004f0  63 6f 72 65 25 0d 01 f4  18 3d 28 78 25 2d 31 29  |core%....=(x%-1)|
00000500  2b 73 69 7a 65 25 2a 28  79 25 2d 31 29 0d ff     |+size%*(y%-1)..|
0000050f