procedure trynextmove on board that is infinite in all directionseach position xy has number candidate moves uvwhich at this point there is no need to specify (see fig the predicate to choose an acceptable move can be expressed as the logical conjunction of the conditions that the new field lies on the boardi < and < nand that it had not been visited previouslyi huv one further detail must not be overlookeda variable huv does exist only if both and lie within the index range - consequentlythe boolean expressionsubstituted for acceptable in the general schemais valid only if its first four constituent terms are true it is therefore relevant that the term huv appears last as resultthe selection of the next acceptable candidate move is expressed by the familiar scheme of linear search (only formulated now in terms of the repeat loop instead of whilewhich in this case is possible and convenientto signal that there are now further candidate movesthe variable eos can be used let us formulate the operation as procedure nextexplicitly specifying the relevant variables as parametersprocedure next (var eosbooleanvar uvinteger)begin (*~eos*repeat select the next candidate move uv until (no more candidatesor (( <= ( < ( <= ( < ( [uv= ))eos :no more candidates end next the enumeration of candidate moves is accomplished in similar procedure first that generates the first candidate movesee the details in the final program presented below just one more refinement step will lead us to program expressed fully in terms of our basic programming notation we should note that so far the program was developed completely independently of the laws governing the jumps of the knight this delaying of considerations of particularities of the problem was quite deliberate but now is the time to take them into account given starting coordinate pair xy there are eight potential candidates uv of the destination they are numbered to in fig fig the possible moves of knight simple method of obtaining uv from xy is by addition of the coordinate differences stored in either an array of difference pairs or in two arrays of single differences let these arrays be denoted by dx and dyappropriately initialized dx ( - - - - dy ( - - - - then an index may be used to number the next candidate the details are shown in the program presented below we assume global matrix representing the resultthe constant (and nsqr )and arrays dx and dy representig the possible moves of knight (see fig the recursive procedure is initiated by call with the coordinates of that field as parameters from which the tour is to start this field must