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

Challenge/Procs/Simple

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/Simple
Read OK:
File size: 041E bytes
Load address: 0000
Exec address: 0000
File contents
   10REM     >Simple (Info18)
   20REM By  Dave Acton
   30REM For 32-bit machines
   40REM (c) BAU June 1993
   50:
   60DEF FNsimple(board%,player%,turn%,size%,first%,left%)
   70LOCAL best_score%,c%(),x%,y%,k%(),xx%,yy%,brd%()
   80IF turn%=-1 THEN =0
   90DIM c%(2),k%(size%+1,size%+1),brd%(size%+1,size%+1)
  100FOR x%=0 TO size%+1
  110 FOR y%=0 TO size%+1
  120  brd%(x%,y%)=board%?((x%+size%-1) MOD size%+size%*((y%+size%-1) MOD size%))
  130 NEXT
  140NEXT
  150k%()=0
  160FOR x%=1 TO size%
  170 FOR y%=1 TO size%
  180  IF brd%(x%,y%)=0 THEN
  190   c%()=0
  200   FOR xx%=-1 TO 1
  210    FOR yy%=-1 TO 1
  220     c%(brd%(x%+xx%,y%+yy%))+=1
  230    NEXT
  240   NEXT
  250   c%(brd%(x%,y%))-=1
  260   IF (c%(1)=1 AND c%(2)=1) OR (c%(player%)=2 AND c%(3-player%)=0) THEN
  270    FOR xx%=-1 TO 1
  280     FOR yy%=-1 TO 1
  290      k%(x%+xx%,y%+yy%)+=1
  300     NEXT
  310    NEXT
  320    k%(x%,y%)-=1
  330   ENDIF
  340  ELSE
  350   k%(x%,y%)=-1000
  360  ENDIF
  370 NEXT
  380NEXT
  390best_score%=-1
  400FOR x%=1 TO size%
  410 FOR y%=1 TO size%
  420  IF brd%(x%,y%)=0 AND k%(x%,y%)>best_score% best_score%=k%(x%,y%)
  430 NEXT
  440NEXT
  450REPEAT
  460 x%=RND(size%)
  470 y%=RND(size%)
  480UNTIL k%(x%,y%)=best_score%
  490=(x%-1)+size%*(y%-1)

�     >Simple (Info18)
� By  Dave Acton
� For 32-bit machines
(� (c) BAU June 1993
2:
<6� �simple(board%,player%,turn%,size%,first%,left%)
F0� best_score%,c%(),x%,y%,k%(),xx%,yy%,brd%()
P� turn%=-1 � =0
Z5� c%(2),k%(size%+1,size%+1),brd%(size%+1,size%+1)
d� x%=0 � size%+1
n � y%=0 � size%+1
xL  brd%(x%,y%)=board%?((x%+size%-1) � size%+size%*((y%+size%-1) � size%))
� �
��
�
k%()=0
�� x%=1 � size%
� � y%=1 � size%
�  � brd%(x%,y%)=0 �
�
   c%()=0
�   � xx%=-1 � 1
�    � yy%=-1 � 1
�#     c%(brd%(x%+xx%,y%+yy%))+=1
�	    �
�   �
�   c%(brd%(x%,y%))-=1
B   � (c%(1)=1 � c%(2)=1) � (c%(player%)=2 � c%(3-player%)=0) �
    � xx%=-1 � 1
     � yy%=-1 � 1
"      k%(x%+xx%,y%+yy%)+=1
,
     �
6	    �
@    k%(x%,y%)-=1
J   �
T  �
^   k%(x%,y%)=-1000
h  �
r �
|�
�best_score%=-1
�� x%=1 � size%
� � y%=1 � size%
�C  � brd%(x%,y%)=0 � k%(x%,y%)>best_score% best_score%=k%(x%,y%)
� �
��
��
� x%=�(size%)
� y%=�(size%)
�� k%(x%,y%)=best_score%
�=(x%-1)+size%*(y%-1)
�
00000000  0d 00 0a 1a f4 20 20 20  20 20 3e 53 69 6d 70 6c  |.....     >Simpl|
00000010  65 20 28 49 6e 66 6f 31  38 29 0d 00 14 14 f4 20  |e (Info18)..... |
00000020  42 79 20 20 44 61 76 65  20 41 63 74 6f 6e 0d 00  |By  Dave Acton..|
00000030  1e 19 f4 20 46 6f 72 20  33 32 2d 62 69 74 20 6d  |... For 32-bit m|
00000040  61 63 68 69 6e 65 73 0d  00 28 17 f4 20 28 63 29  |achines..(.. (c)|
00000050  20 42 41 55 20 4a 75 6e  65 20 31 39 39 33 0d 00  | BAU June 1993..|
00000060  32 05 3a 0d 00 3c 36 dd  20 a4 73 69 6d 70 6c 65  |2.:..<6. .simple|
00000070  28 62 6f 61 72 64 25 2c  70 6c 61 79 65 72 25 2c  |(board%,player%,|
00000080  74 75 72 6e 25 2c 73 69  7a 65 25 2c 66 69 72 73  |turn%,size%,firs|
00000090  74 25 2c 6c 65 66 74 25  29 0d 00 46 30 ea 20 62  |t%,left%)..F0. b|
000000a0  65 73 74 5f 73 63 6f 72  65 25 2c 63 25 28 29 2c  |est_score%,c%(),|
000000b0  78 25 2c 79 25 2c 6b 25  28 29 2c 78 78 25 2c 79  |x%,y%,k%(),xx%,y|
000000c0  79 25 2c 62 72 64 25 28  29 0d 00 50 13 e7 20 74  |y%,brd%()..P.. t|
000000d0  75 72 6e 25 3d 2d 31 20  8c 20 3d 30 0d 00 5a 35  |urn%=-1 . =0..Z5|
000000e0  de 20 63 25 28 32 29 2c  6b 25 28 73 69 7a 65 25  |. c%(2),k%(size%|
000000f0  2b 31 2c 73 69 7a 65 25  2b 31 29 2c 62 72 64 25  |+1,size%+1),brd%|
00000100  28 73 69 7a 65 25 2b 31  2c 73 69 7a 65 25 2b 31  |(size%+1,size%+1|
00000110  29 0d 00 64 14 e3 20 78  25 3d 30 20 b8 20 73 69  |)..d.. x%=0 . si|
00000120  7a 65 25 2b 31 0d 00 6e  15 20 e3 20 79 25 3d 30  |ze%+1..n. . y%=0|
00000130  20 b8 20 73 69 7a 65 25  2b 31 0d 00 78 4c 20 20  | . size%+1..xL  |
00000140  62 72 64 25 28 78 25 2c  79 25 29 3d 62 6f 61 72  |brd%(x%,y%)=boar|
00000150  64 25 3f 28 28 78 25 2b  73 69 7a 65 25 2d 31 29  |d%?((x%+size%-1)|
00000160  20 83 20 73 69 7a 65 25  2b 73 69 7a 65 25 2a 28  | . size%+size%*(|
00000170  28 79 25 2b 73 69 7a 65  25 2d 31 29 20 83 20 73  |(y%+size%-1) . s|
00000180  69 7a 65 25 29 29 0d 00  82 06 20 ed 0d 00 8c 05  |ize%)).... .....|
00000190  ed 0d 00 96 0a 6b 25 28  29 3d 30 0d 00 a0 12 e3  |.....k%()=0.....|
000001a0  20 78 25 3d 31 20 b8 20  73 69 7a 65 25 0d 00 aa  | x%=1 . size%...|
000001b0  13 20 e3 20 79 25 3d 31  20 b8 20 73 69 7a 65 25  |. . y%=1 . size%|
000001c0  0d 00 b4 17 20 20 e7 20  62 72 64 25 28 78 25 2c  |....  . brd%(x%,|
000001d0  79 25 29 3d 30 20 8c 0d  00 be 0d 20 20 20 63 25  |y%)=0 .....   c%|
000001e0  28 29 3d 30 0d 00 c8 13  20 20 20 e3 20 78 78 25  |()=0....   . xx%|
000001f0  3d 2d 31 20 b8 20 31 0d  00 d2 14 20 20 20 20 e3  |=-1 . 1....    .|
00000200  20 79 79 25 3d 2d 31 20  b8 20 31 0d 00 dc 23 20  | yy%=-1 . 1...# |
00000210  20 20 20 20 63 25 28 62  72 64 25 28 78 25 2b 78  |    c%(brd%(x%+x|
00000220  78 25 2c 79 25 2b 79 79  25 29 29 2b 3d 31 0d 00  |x%,y%+yy%))+=1..|
00000230  e6 09 20 20 20 20 ed 0d  00 f0 08 20 20 20 ed 0d  |..    .....   ..|
00000240  00 fa 19 20 20 20 63 25  28 62 72 64 25 28 78 25  |...   c%(brd%(x%|
00000250  2c 79 25 29 29 2d 3d 31  0d 01 04 42 20 20 20 e7  |,y%))-=1...B   .|
00000260  20 28 63 25 28 31 29 3d  31 20 80 20 63 25 28 32  | (c%(1)=1 . c%(2|
00000270  29 3d 31 29 20 84 20 28  63 25 28 70 6c 61 79 65  |)=1) . (c%(playe|
00000280  72 25 29 3d 32 20 80 20  63 25 28 33 2d 70 6c 61  |r%)=2 . c%(3-pla|
00000290  79 65 72 25 29 3d 30 29  20 8c 0d 01 0e 14 20 20  |yer%)=0) .....  |
000002a0  20 20 e3 20 78 78 25 3d  2d 31 20 b8 20 31 0d 01  |  . xx%=-1 . 1..|
000002b0  18 15 20 20 20 20 20 e3  20 79 79 25 3d 2d 31 20  |..     . yy%=-1 |
000002c0  b8 20 31 0d 01 22 1e 20  20 20 20 20 20 6b 25 28  |. 1..".      k%(|
000002d0  78 25 2b 78 78 25 2c 79  25 2b 79 79 25 29 2b 3d  |x%+xx%,y%+yy%)+=|
000002e0  31 0d 01 2c 0a 20 20 20  20 20 ed 0d 01 36 09 20  |1..,.     ...6. |
000002f0  20 20 20 ed 0d 01 40 14  20 20 20 20 6b 25 28 78  |   ...@.    k%(x|
00000300  25 2c 79 25 29 2d 3d 31  0d 01 4a 08 20 20 20 cd  |%,y%)-=1..J.   .|
00000310  0d 01 54 07 20 20 cc 0d  01 5e 16 20 20 20 6b 25  |..T.  ...^.   k%|
00000320  28 78 25 2c 79 25 29 3d  2d 31 30 30 30 0d 01 68  |(x%,y%)=-1000..h|
00000330  07 20 20 cd 0d 01 72 06  20 ed 0d 01 7c 05 ed 0d  |.  ...r. ...|...|
00000340  01 86 12 62 65 73 74 5f  73 63 6f 72 65 25 3d 2d  |...best_score%=-|
00000350  31 0d 01 90 12 e3 20 78  25 3d 31 20 b8 20 73 69  |1..... x%=1 . si|
00000360  7a 65 25 0d 01 9a 13 20  e3 20 79 25 3d 31 20 b8  |ze%.... . y%=1 .|
00000370  20 73 69 7a 65 25 0d 01  a4 43 20 20 e7 20 62 72  | size%...C  . br|
00000380  64 25 28 78 25 2c 79 25  29 3d 30 20 80 20 6b 25  |d%(x%,y%)=0 . k%|
00000390  28 78 25 2c 79 25 29 3e  62 65 73 74 5f 73 63 6f  |(x%,y%)>best_sco|
000003a0  72 65 25 20 62 65 73 74  5f 73 63 6f 72 65 25 3d  |re% best_score%=|
000003b0  6b 25 28 78 25 2c 79 25  29 0d 01 ae 06 20 ed 0d  |k%(x%,y%).... ..|
000003c0  01 b8 05 ed 0d 01 c2 05  f5 0d 01 cc 10 20 78 25  |............. x%|
000003d0  3d b3 28 73 69 7a 65 25  29 0d 01 d6 10 20 79 25  |=.(size%).... y%|
000003e0  3d b3 28 73 69 7a 65 25  29 0d 01 e0 1b fd 20 6b  |=.(size%)..... k|
000003f0  25 28 78 25 2c 79 25 29  3d 62 65 73 74 5f 73 63  |%(x%,y%)=best_sc|
00000400  6f 72 65 25 0d 01 ea 18  3d 28 78 25 2d 31 29 2b  |ore%....=(x%-1)+|
00000410  73 69 7a 65 25 2a 28 79  25 2d 31 29 0d ff        |size%*(y%-1)..|
0000041e