Home » CEEFAX disks » telesoftware16.adl » 14-07-89/PKnight

14-07-89/PKnight

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 » CEEFAX disks » telesoftware16.adl
Filename: 14-07-89/PKnight
Read OK:
File size: 0BE6 bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
PROGRAM KnightsTour(INPUT,OUTPUT);
{ A program to simulate the Knights Tour problem of trying to move a single
   knight around an empty chess board such that it only visits each square
   once.
   Rob Anderson. June '88
}

CONST
  boardxsize = 4;
  boardysize = 5;
  xstart = 1;
  ystart = 1;

TYPE
 legalmoves = ARRAY [1..8] OF RECORD              { holds 8 possible moves }
                                dx, dy : INTEGER; { of a knight            }
                              END;

 square = ARRAY [ 1..boardxsize, 1..boardysize ] OF INTEGER;

VAR
  board      : square;
  legal      : legalmoves;
  finishedok : BOOLEAN;
  x , y      : INTEGER;


{ ----------------------------- initialise --------------------------------- }

PROCEDURE initialise;

VAR loop1, loop2 : INTEGER;

BEGIN

  WRITELN('The Knights Tour.');
  WRITELN('-----------------');

  { clear the board initially }
  FOR loop1 := 1 to boardxsize DO
  BEGIN
    FOR loop2 := 1 to boardysize DO
      board[loop1,loop2] := 0;
  END; { for loop 1 }

  { define the legal moves of a knight }
  legal[1].dx := -1; legal[1].dy := -2;
  legal[2].dx := -1; legal[2].dy := +2;
  legal[3].dx := +1; legal[3].dy := -2;
  legal[4].dx := +1; legal[4].dy := +2;
  legal[5].dx := -2; legal[5].dy := -1;
  legal[6].dx := +2; legal[6].dy := -1;
  legal[7].dx := -2; legal[7].dy := +1;
  legal[8].dx := +2; legal[8].dy := +1;

END; { initialise }


{ ------------------------------- trymove ---------------------------------- }

PROCEDURE trymove(movenum, x, y : INTEGER; VAR success : BOOLEAN);

VAR
  trynumber : INTEGER;
  goodmove  : BOOLEAN;
  i , j     : INTEGER;

BEGIN

  trynumber := 0;

  { Output the move number if it is greater than 95% of that required to  }
  { obtain a solution.                                                    }
  IF (movenum > (boardxsize*boardysize/100*95)) THEN
    WRITELN('one path getting close; move number = ',movenum-1);

  REPEAT
    trynumber := trynumber + 1;
    goodmove := FALSE;
    i := x + legal[trynumber].dx;
    j := y + legal[trynumber].dy;

    IF (i >= 1) AND (i <= boardxsize) AND (j >= 1) AND (j <= boardysize)
    THEN
    BEGIN
      IF (board[i,j] = 0)
      THEN
      BEGIN
        board[i,j] := movenum;
        IF (movenum = (boardxsize*boardysize))
        THEN goodmove := TRUE
        ELSE
        BEGIN
          trymove(movenum + 1, i, j, goodmove);
          IF NOT(goodmove) THEN board[i,j] := 0;
        END; { else }
      END; { if }
    END; { if }
  UNTIL goodmove OR (trynumber = 8);

  success := goodmove;

END; { trymove }


{ ---------------------------- main program --------------------------------- }

BEGIN

  initialise;

  board[xstart,ystart] := 1;
  trymove(2,xstart,ystart,finishedok);
  WRITELN;

  IF finishedok
  THEN
  BEGIN

    WRITELN('A path has been found; ');
    FOR y := boardysize DOWNTO 1 DO
    BEGIN
      FOR x := 1 TO boardxsize DO
        WRITE( board[x,y] : 3);
      WRITELN;
    END; { for x }

  END { then }
  ELSE WRITELN('No path is available.');

  WRITELN;

END.
00000000  50 52 4f 47 52 41 4d 20  4b 6e 69 67 68 74 73 54  |PROGRAM KnightsT|
00000010  6f 75 72 28 49 4e 50 55  54 2c 4f 55 54 50 55 54  |our(INPUT,OUTPUT|
00000020  29 3b 0d 7b 20 41 20 70  72 6f 67 72 61 6d 20 74  |);.{ A program t|
00000030  6f 20 73 69 6d 75 6c 61  74 65 20 74 68 65 20 4b  |o simulate the K|
00000040  6e 69 67 68 74 73 20 54  6f 75 72 20 70 72 6f 62  |nights Tour prob|
00000050  6c 65 6d 20 6f 66 20 74  72 79 69 6e 67 20 74 6f  |lem of trying to|
00000060  20 6d 6f 76 65 20 61 20  73 69 6e 67 6c 65 0d 20  | move a single. |
00000070  20 20 6b 6e 69 67 68 74  20 61 72 6f 75 6e 64 20  |  knight around |
00000080  61 6e 20 65 6d 70 74 79  20 63 68 65 73 73 20 62  |an empty chess b|
00000090  6f 61 72 64 20 73 75 63  68 20 74 68 61 74 20 69  |oard such that i|
000000a0  74 20 6f 6e 6c 79 20 76  69 73 69 74 73 20 65 61  |t only visits ea|
000000b0  63 68 20 73 71 75 61 72  65 0d 20 20 20 6f 6e 63  |ch square.   onc|
000000c0  65 2e 0d 20 20 20 52 6f  62 20 41 6e 64 65 72 73  |e..   Rob Anders|
000000d0  6f 6e 2e 20 4a 75 6e 65  20 27 38 38 0d 7d 0d 0d  |on. June '88.}..|
000000e0  43 4f 4e 53 54 0d 20 20  62 6f 61 72 64 78 73 69  |CONST.  boardxsi|
000000f0  7a 65 20 3d 20 34 3b 0d  20 20 62 6f 61 72 64 79  |ze = 4;.  boardy|
00000100  73 69 7a 65 20 3d 20 35  3b 0d 20 20 78 73 74 61  |size = 5;.  xsta|
00000110  72 74 20 3d 20 31 3b 0d  20 20 79 73 74 61 72 74  |rt = 1;.  ystart|
00000120  20 3d 20 31 3b 0d 0d 54  59 50 45 0d 20 6c 65 67  | = 1;..TYPE. leg|
00000130  61 6c 6d 6f 76 65 73 20  3d 20 41 52 52 41 59 20  |almoves = ARRAY |
00000140  5b 31 2e 2e 38 5d 20 4f  46 20 52 45 43 4f 52 44  |[1..8] OF RECORD|
00000150  20 20 20 20 20 20 20 20  20 20 20 20 20 20 7b 20  |              { |
00000160  68 6f 6c 64 73 20 38 20  70 6f 73 73 69 62 6c 65  |holds 8 possible|
00000170  20 6d 6f 76 65 73 20 7d  0d 20 20 20 20 20 20 20  | moves }.       |
00000180  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000190  20 20 20 20 20 20 20 20  20 64 78 2c 20 64 79 20  |         dx, dy |
000001a0  3a 20 49 4e 54 45 47 45  52 3b 20 7b 20 6f 66 20  |: INTEGER; { of |
000001b0  61 20 6b 6e 69 67 68 74  20 20 20 20 20 20 20 20  |a knight        |
000001c0  20 20 20 20 7d 0d 20 20  20 20 20 20 20 20 20 20  |    }.          |
000001d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000001e0  20 20 20 20 45 4e 44 3b  0d 0d 20 73 71 75 61 72  |    END;.. squar|
000001f0  65 20 3d 20 41 52 52 41  59 20 5b 20 31 2e 2e 62  |e = ARRAY [ 1..b|
00000200  6f 61 72 64 78 73 69 7a  65 2c 20 31 2e 2e 62 6f  |oardxsize, 1..bo|
00000210  61 72 64 79 73 69 7a 65  20 5d 20 4f 46 20 49 4e  |ardysize ] OF IN|
00000220  54 45 47 45 52 3b 0d 0d  56 41 52 0d 20 20 62 6f  |TEGER;..VAR.  bo|
00000230  61 72 64 20 20 20 20 20  20 3a 20 73 71 75 61 72  |ard      : squar|
00000240  65 3b 0d 20 20 6c 65 67  61 6c 20 20 20 20 20 20  |e;.  legal      |
00000250  3a 20 6c 65 67 61 6c 6d  6f 76 65 73 3b 0d 20 20  |: legalmoves;.  |
00000260  66 69 6e 69 73 68 65 64  6f 6b 20 3a 20 42 4f 4f  |finishedok : BOO|
00000270  4c 45 41 4e 3b 0d 20 20  78 20 2c 20 79 20 20 20  |LEAN;.  x , y   |
00000280  20 20 20 3a 20 49 4e 54  45 47 45 52 3b 0d 0d 0d  |   : INTEGER;...|
00000290  7b 20 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |{ --------------|
000002a0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 20  |--------------- |
000002b0  69 6e 69 74 69 61 6c 69  73 65 20 2d 2d 2d 2d 2d  |initialise -----|
000002c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000002d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 20 7d 0d 0d  |------------ }..|
000002e0  50 52 4f 43 45 44 55 52  45 20 69 6e 69 74 69 61  |PROCEDURE initia|
000002f0  6c 69 73 65 3b 0d 0d 56  41 52 20 6c 6f 6f 70 31  |lise;..VAR loop1|
00000300  2c 20 6c 6f 6f 70 32 20  3a 20 49 4e 54 45 47 45  |, loop2 : INTEGE|
00000310  52 3b 0d 0d 42 45 47 49  4e 0d 0d 20 20 57 52 49  |R;..BEGIN..  WRI|
00000320  54 45 4c 4e 28 27 54 68  65 20 4b 6e 69 67 68 74  |TELN('The Knight|
00000330  73 20 54 6f 75 72 2e 27  29 3b 0d 20 20 57 52 49  |s Tour.');.  WRI|
00000340  54 45 4c 4e 28 27 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |TELN('----------|
00000350  2d 2d 2d 2d 2d 2d 2d 27  29 3b 0d 0d 20 20 7b 20  |-------');..  { |
00000360  63 6c 65 61 72 20 74 68  65 20 62 6f 61 72 64 20  |clear the board |
00000370  69 6e 69 74 69 61 6c 6c  79 20 7d 0d 20 20 46 4f  |initially }.  FO|
00000380  52 20 6c 6f 6f 70 31 20  3a 3d 20 31 20 74 6f 20  |R loop1 := 1 to |
00000390  62 6f 61 72 64 78 73 69  7a 65 20 44 4f 0d 20 20  |boardxsize DO.  |
000003a0  42 45 47 49 4e 0d 20 20  20 20 46 4f 52 20 6c 6f  |BEGIN.    FOR lo|
000003b0  6f 70 32 20 3a 3d 20 31  20 74 6f 20 62 6f 61 72  |op2 := 1 to boar|
000003c0  64 79 73 69 7a 65 20 44  4f 0d 20 20 20 20 20 20  |dysize DO.      |
000003d0  62 6f 61 72 64 5b 6c 6f  6f 70 31 2c 6c 6f 6f 70  |board[loop1,loop|
000003e0  32 5d 20 3a 3d 20 30 3b  0d 20 20 45 4e 44 3b 20  |2] := 0;.  END; |
000003f0  7b 20 66 6f 72 20 6c 6f  6f 70 20 31 20 7d 0d 0d  |{ for loop 1 }..|
00000400  20 20 7b 20 64 65 66 69  6e 65 20 74 68 65 20 6c  |  { define the l|
00000410  65 67 61 6c 20 6d 6f 76  65 73 20 6f 66 20 61 20  |egal moves of a |
00000420  6b 6e 69 67 68 74 20 7d  0d 20 20 6c 65 67 61 6c  |knight }.  legal|
00000430  5b 31 5d 2e 64 78 20 3a  3d 20 2d 31 3b 20 6c 65  |[1].dx := -1; le|
00000440  67 61 6c 5b 31 5d 2e 64  79 20 3a 3d 20 2d 32 3b  |gal[1].dy := -2;|
00000450  0d 20 20 6c 65 67 61 6c  5b 32 5d 2e 64 78 20 3a  |.  legal[2].dx :|
00000460  3d 20 2d 31 3b 20 6c 65  67 61 6c 5b 32 5d 2e 64  |= -1; legal[2].d|
00000470  79 20 3a 3d 20 2b 32 3b  0d 20 20 6c 65 67 61 6c  |y := +2;.  legal|
00000480  5b 33 5d 2e 64 78 20 3a  3d 20 2b 31 3b 20 6c 65  |[3].dx := +1; le|
00000490  67 61 6c 5b 33 5d 2e 64  79 20 3a 3d 20 2d 32 3b  |gal[3].dy := -2;|
000004a0  0d 20 20 6c 65 67 61 6c  5b 34 5d 2e 64 78 20 3a  |.  legal[4].dx :|
000004b0  3d 20 2b 31 3b 20 6c 65  67 61 6c 5b 34 5d 2e 64  |= +1; legal[4].d|
000004c0  79 20 3a 3d 20 2b 32 3b  0d 20 20 6c 65 67 61 6c  |y := +2;.  legal|
000004d0  5b 35 5d 2e 64 78 20 3a  3d 20 2d 32 3b 20 6c 65  |[5].dx := -2; le|
000004e0  67 61 6c 5b 35 5d 2e 64  79 20 3a 3d 20 2d 31 3b  |gal[5].dy := -1;|
000004f0  0d 20 20 6c 65 67 61 6c  5b 36 5d 2e 64 78 20 3a  |.  legal[6].dx :|
00000500  3d 20 2b 32 3b 20 6c 65  67 61 6c 5b 36 5d 2e 64  |= +2; legal[6].d|
00000510  79 20 3a 3d 20 2d 31 3b  0d 20 20 6c 65 67 61 6c  |y := -1;.  legal|
00000520  5b 37 5d 2e 64 78 20 3a  3d 20 2d 32 3b 20 6c 65  |[7].dx := -2; le|
00000530  67 61 6c 5b 37 5d 2e 64  79 20 3a 3d 20 2b 31 3b  |gal[7].dy := +1;|
00000540  0d 20 20 6c 65 67 61 6c  5b 38 5d 2e 64 78 20 3a  |.  legal[8].dx :|
00000550  3d 20 2b 32 3b 20 6c 65  67 61 6c 5b 38 5d 2e 64  |= +2; legal[8].d|
00000560  79 20 3a 3d 20 2b 31 3b  0d 0d 45 4e 44 3b 20 7b  |y := +1;..END; {|
00000570  20 69 6e 69 74 69 61 6c  69 73 65 20 7d 0d 0d 0d  | initialise }...|
00000580  7b 20 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |{ --------------|
00000590  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000005a0  2d 20 74 72 79 6d 6f 76  65 20 2d 2d 2d 2d 2d 2d  |- trymove ------|
000005b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000005c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 20 7d 0d 0d  |------------ }..|
000005d0  50 52 4f 43 45 44 55 52  45 20 74 72 79 6d 6f 76  |PROCEDURE trymov|
000005e0  65 28 6d 6f 76 65 6e 75  6d 2c 20 78 2c 20 79 20  |e(movenum, x, y |
000005f0  3a 20 49 4e 54 45 47 45  52 3b 20 56 41 52 20 73  |: INTEGER; VAR s|
00000600  75 63 63 65 73 73 20 3a  20 42 4f 4f 4c 45 41 4e  |uccess : BOOLEAN|
00000610  29 3b 0d 0d 56 41 52 0d  20 20 74 72 79 6e 75 6d  |);..VAR.  trynum|
00000620  62 65 72 20 3a 20 49 4e  54 45 47 45 52 3b 0d 20  |ber : INTEGER;. |
00000630  20 67 6f 6f 64 6d 6f 76  65 20 20 3a 20 42 4f 4f  | goodmove  : BOO|
00000640  4c 45 41 4e 3b 0d 20 20  69 20 2c 20 6a 20 20 20  |LEAN;.  i , j   |
00000650  20 20 3a 20 49 4e 54 45  47 45 52 3b 0d 0d 42 45  |  : INTEGER;..BE|
00000660  47 49 4e 0d 0d 20 20 74  72 79 6e 75 6d 62 65 72  |GIN..  trynumber|
00000670  20 3a 3d 20 30 3b 0d 0d  20 20 7b 20 4f 75 74 70  | := 0;..  { Outp|
00000680  75 74 20 74 68 65 20 6d  6f 76 65 20 6e 75 6d 62  |ut the move numb|
00000690  65 72 20 69 66 20 69 74  20 69 73 20 67 72 65 61  |er if it is grea|
000006a0  74 65 72 20 74 68 61 6e  20 39 35 25 20 6f 66 20  |ter than 95% of |
000006b0  74 68 61 74 20 72 65 71  75 69 72 65 64 20 74 6f  |that required to|
000006c0  20 20 7d 0d 20 20 7b 20  6f 62 74 61 69 6e 20 61  |  }.  { obtain a|
000006d0  20 73 6f 6c 75 74 69 6f  6e 2e 20 20 20 20 20 20  | solution.      |
000006e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000700  20 20 20 20 20 20 20 20  20 20 20 20 20 20 7d 0d  |              }.|
00000710  20 20 49 46 20 28 6d 6f  76 65 6e 75 6d 20 3e 20  |  IF (movenum > |
00000720  28 62 6f 61 72 64 78 73  69 7a 65 2a 62 6f 61 72  |(boardxsize*boar|
00000730  64 79 73 69 7a 65 2f 31  30 30 2a 39 35 29 29 20  |dysize/100*95)) |
00000740  54 48 45 4e 0d 20 20 20  20 57 52 49 54 45 4c 4e  |THEN.    WRITELN|
00000750  28 27 6f 6e 65 20 70 61  74 68 20 67 65 74 74 69  |('one path getti|
00000760  6e 67 20 63 6c 6f 73 65  3b 20 6d 6f 76 65 20 6e  |ng close; move n|
00000770  75 6d 62 65 72 20 3d 20  27 2c 6d 6f 76 65 6e 75  |umber = ',movenu|
00000780  6d 2d 31 29 3b 0d 0d 20  20 52 45 50 45 41 54 0d  |m-1);..  REPEAT.|
00000790  20 20 20 20 74 72 79 6e  75 6d 62 65 72 20 3a 3d  |    trynumber :=|
000007a0  20 74 72 79 6e 75 6d 62  65 72 20 2b 20 31 3b 0d  | trynumber + 1;.|
000007b0  20 20 20 20 67 6f 6f 64  6d 6f 76 65 20 3a 3d 20  |    goodmove := |
000007c0  46 41 4c 53 45 3b 0d 20  20 20 20 69 20 3a 3d 20  |FALSE;.    i := |
000007d0  78 20 2b 20 6c 65 67 61  6c 5b 74 72 79 6e 75 6d  |x + legal[trynum|
000007e0  62 65 72 5d 2e 64 78 3b  0d 20 20 20 20 6a 20 3a  |ber].dx;.    j :|
000007f0  3d 20 79 20 2b 20 6c 65  67 61 6c 5b 74 72 79 6e  |= y + legal[tryn|
00000800  75 6d 62 65 72 5d 2e 64  79 3b 0d 0d 20 20 20 20  |umber].dy;..    |
00000810  49 46 20 28 69 20 3e 3d  20 31 29 20 41 4e 44 20  |IF (i >= 1) AND |
00000820  28 69 20 3c 3d 20 62 6f  61 72 64 78 73 69 7a 65  |(i <= boardxsize|
00000830  29 20 41 4e 44 20 28 6a  20 3e 3d 20 31 29 20 41  |) AND (j >= 1) A|
00000840  4e 44 20 28 6a 20 3c 3d  20 62 6f 61 72 64 79 73  |ND (j <= boardys|
00000850  69 7a 65 29 0d 20 20 20  20 54 48 45 4e 0d 20 20  |ize).    THEN.  |
00000860  20 20 42 45 47 49 4e 0d  20 20 20 20 20 20 49 46  |  BEGIN.      IF|
00000870  20 28 62 6f 61 72 64 5b  69 2c 6a 5d 20 3d 20 30  | (board[i,j] = 0|
00000880  29 0d 20 20 20 20 20 20  54 48 45 4e 0d 20 20 20  |).      THEN.   |
00000890  20 20 20 42 45 47 49 4e  0d 20 20 20 20 20 20 20  |   BEGIN.       |
000008a0  20 62 6f 61 72 64 5b 69  2c 6a 5d 20 3a 3d 20 6d  | board[i,j] := m|
000008b0  6f 76 65 6e 75 6d 3b 0d  20 20 20 20 20 20 20 20  |ovenum;.        |
000008c0  49 46 20 28 6d 6f 76 65  6e 75 6d 20 3d 20 28 62  |IF (movenum = (b|
000008d0  6f 61 72 64 78 73 69 7a  65 2a 62 6f 61 72 64 79  |oardxsize*boardy|
000008e0  73 69 7a 65 29 29 0d 20  20 20 20 20 20 20 20 54  |size)).        T|
000008f0  48 45 4e 20 67 6f 6f 64  6d 6f 76 65 20 3a 3d 20  |HEN goodmove := |
00000900  54 52 55 45 0d 20 20 20  20 20 20 20 20 45 4c 53  |TRUE.        ELS|
00000910  45 0d 20 20 20 20 20 20  20 20 42 45 47 49 4e 0d  |E.        BEGIN.|
00000920  20 20 20 20 20 20 20 20  20 20 74 72 79 6d 6f 76  |          trymov|
00000930  65 28 6d 6f 76 65 6e 75  6d 20 2b 20 31 2c 20 69  |e(movenum + 1, i|
00000940  2c 20 6a 2c 20 67 6f 6f  64 6d 6f 76 65 29 3b 0d  |, j, goodmove);.|
00000950  20 20 20 20 20 20 20 20  20 20 49 46 20 4e 4f 54  |          IF NOT|
00000960  28 67 6f 6f 64 6d 6f 76  65 29 20 54 48 45 4e 20  |(goodmove) THEN |
00000970  62 6f 61 72 64 5b 69 2c  6a 5d 20 3a 3d 20 30 3b  |board[i,j] := 0;|
00000980  0d 20 20 20 20 20 20 20  20 45 4e 44 3b 20 7b 20  |.        END; { |
00000990  65 6c 73 65 20 7d 0d 20  20 20 20 20 20 45 4e 44  |else }.      END|
000009a0  3b 20 7b 20 69 66 20 7d  0d 20 20 20 20 45 4e 44  |; { if }.    END|
000009b0  3b 20 7b 20 69 66 20 7d  0d 20 20 55 4e 54 49 4c  |; { if }.  UNTIL|
000009c0  20 67 6f 6f 64 6d 6f 76  65 20 4f 52 20 28 74 72  | goodmove OR (tr|
000009d0  79 6e 75 6d 62 65 72 20  3d 20 38 29 3b 0d 0d 20  |ynumber = 8);.. |
000009e0  20 73 75 63 63 65 73 73  20 3a 3d 20 67 6f 6f 64  | success := good|
000009f0  6d 6f 76 65 3b 0d 0d 45  4e 44 3b 20 7b 20 74 72  |move;..END; { tr|
00000a00  79 6d 6f 76 65 20 7d 0d  0d 0d 7b 20 2d 2d 2d 2d  |ymove }...{ ----|
00000a10  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000a20  2d 2d 2d 2d 2d 2d 2d 2d  20 6d 61 69 6e 20 70 72  |-------- main pr|
00000a30  6f 67 72 61 6d 20 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |ogram ----------|
00000a40  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000a50  2d 2d 2d 2d 2d 2d 2d 20  7d 0d 0d 42 45 47 49 4e  |------- }..BEGIN|
00000a60  0d 0d 20 20 69 6e 69 74  69 61 6c 69 73 65 3b 0d  |..  initialise;.|
00000a70  0d 20 20 62 6f 61 72 64  5b 78 73 74 61 72 74 2c  |.  board[xstart,|
00000a80  79 73 74 61 72 74 5d 20  3a 3d 20 31 3b 0d 20 20  |ystart] := 1;.  |
00000a90  74 72 79 6d 6f 76 65 28  32 2c 78 73 74 61 72 74  |trymove(2,xstart|
00000aa0  2c 79 73 74 61 72 74 2c  66 69 6e 69 73 68 65 64  |,ystart,finished|
00000ab0  6f 6b 29 3b 0d 20 20 57  52 49 54 45 4c 4e 3b 0d  |ok);.  WRITELN;.|
00000ac0  0d 20 20 49 46 20 66 69  6e 69 73 68 65 64 6f 6b  |.  IF finishedok|
00000ad0  0d 20 20 54 48 45 4e 0d  20 20 42 45 47 49 4e 0d  |.  THEN.  BEGIN.|
00000ae0  0d 20 20 20 20 57 52 49  54 45 4c 4e 28 27 41 20  |.    WRITELN('A |
00000af0  70 61 74 68 20 68 61 73  20 62 65 65 6e 20 66 6f  |path has been fo|
00000b00  75 6e 64 3b 20 27 29 3b  0d 20 20 20 20 46 4f 52  |und; ');.    FOR|
00000b10  20 79 20 3a 3d 20 62 6f  61 72 64 79 73 69 7a 65  | y := boardysize|
00000b20  20 44 4f 57 4e 54 4f 20  31 20 44 4f 0d 20 20 20  | DOWNTO 1 DO.   |
00000b30  20 42 45 47 49 4e 0d 20  20 20 20 20 20 46 4f 52  | BEGIN.      FOR|
00000b40  20 78 20 3a 3d 20 31 20  54 4f 20 62 6f 61 72 64  | x := 1 TO board|
00000b50  78 73 69 7a 65 20 44 4f  0d 20 20 20 20 20 20 20  |xsize DO.       |
00000b60  20 57 52 49 54 45 28 20  62 6f 61 72 64 5b 78 2c  | WRITE( board[x,|
00000b70  79 5d 20 3a 20 33 29 3b  0d 20 20 20 20 20 20 57  |y] : 3);.      W|
00000b80  52 49 54 45 4c 4e 3b 0d  20 20 20 20 45 4e 44 3b  |RITELN;.    END;|
00000b90  20 7b 20 66 6f 72 20 78  20 7d 0d 0d 20 20 45 4e  | { for x }..  EN|
00000ba0  44 20 7b 20 74 68 65 6e  20 7d 0d 20 20 45 4c 53  |D { then }.  ELS|
00000bb0  45 20 57 52 49 54 45 4c  4e 28 27 4e 6f 20 70 61  |E WRITELN('No pa|
00000bc0  74 68 20 69 73 20 61 76  61 69 6c 61 62 6c 65 2e  |th is available.|
00000bd0  27 29 3b 0d 0d 20 20 57  52 49 54 45 4c 4e 3b 0d  |');..  WRITELN;.|
00000be0  0d 45 4e 44 2e 0d                                 |.END..|
00000be6
14-07-89/PKnight.m0
14-07-89/PKnight.m1
14-07-89/PKnight.m2
14-07-89/PKnight.m4
14-07-89/PKnight.m5