360 Supporting On Demand Business Applications with the IBM Problem Determination Tools

/* - - - - - */

/* | |b| | | | */

/* - - - - - */

/**************************************************************/

dcl rowjump(8) fixed bin(15)

static init(-2,-1,+2,-1,+1,+1,+2,-2);

dcl coljump(8) fixed bin(15)

static init(+1,+2,-1,-2,+2,-2,-1,-1);

/**************************************************************/

/* the land array holds for each square the number of the */

/* move when the knight landed on that square. */

/**************************************************************/

dcl land(size,size) pic'ZZZ9';

/**************************************************************/

/* the rank array holds a ranking for each square to which */

/* the knight could move - this includes squares in the */

/* two imaginary rows and columns that surround the board. */

/* the knight will move to the square with the lowest */

/* positive rank. */

/* the rank of all squares off the board is zero, and */

/* consequently the knight will never move off the board. */

/* the rank of all other squares is equal to the number */

/* of moves possible from that square. thus, initially */

/* the rank of the four corner squares is 2. */

/**************************************************************/

dcl rank(-1:2+size,-1:2+size) fixed bin(7);

/**************************************************************/

/* the following variables are used for temporary purposes. */

/**************************************************************/

dcl (minrank,minmove) fixed bin(15);

dcl testrank fixed bin(15);

dcl (m,r,c,k) fixed bin(15);

/**************************************************************/

/* note that rankings are kept for two rows or columns */

/* beyond the real edges of the board. */

/* initialize all those rankings */

/* the rank of a square to which the knight should not move */

/* will be zero. hence the initial rank of all the squares */

/* off the board is zero. */

/**************************************************************/

call initialize_Rankings;

/**************************************************************/

/* initialize all those moves to zero. */

/**************************************************************/

land = 0;

/**************************************************************/

/* make the first move in the tour */

/**************************************************************/

m = 1;

r = 1; c = 1;

land(r,c) = m;

/**************************************************************/

/* determine the moves in the tour */

/**************************************************************/

do while ( m < size*size ) until ( minrank = 0 );