🕸📝Fergus Duniho wrote on Sat, Jan 1, 2005 03:31 AM UTC:
I added the following new functions to the Polish notation calculator
today:
checkmaxsteps
checknsteps
checkpath
These all handle movement that may go along a winding, unobstructed path,
such as the movement of some pieces in Jetan. The checkmaxsteps function
checks whether a piece may move from one space to another within a
specified number of steps from one adjacent space to another. The
checknsteps function checks whether a piece may move from one space to
another in exactly a specified number of steps. Both of these functions
allow movement through the origin space and repeated movement through the
same space. They are both handled by a recursive function that goes
through all possible paths until it finds one that works. The checkpath
function checks whether a piece can move from one space to another by
following a specific path, given as a set of paired directions. To
illustrate how these work, here are two alternate ways to handle the
Squire from Holywar:
Barring possible mistakes, here is the long way that uses 16 checkpath
functions for all possible paths:
checkpath origin dest (1 0 1 1) or checkpath origin dest (1 1 1 0) or
checkpath origin dest (1 0 1 -1) or checkpath origin dest (1 -1 1 0) or
checkpath origin dest (-1 0 -1 1) or checkpath origin dest (-1 1 -1 0) or
checkpath origin dest (-1 0 -1 -1) or checkpath origin dest (-1 -1 -1 0)
or
checkpath origin dest (0 1 1 1) or checkpath origin dest (1 1 0 -1) or
checkpath origin dest (0 1 -1 1) or checkpath origin dest (-1 1 0 -1) or
checkpath origin dest (0 -1 1 1) or checkpath origin dest (1 1 0 1) or
checkpath origin dest (0 -1 1 -1) or checkpath origin dest (1 -1 0 1);
Here is the short way that uses checknsteps in combination with
checkleap:
checkleap origin dest 1 2 and checknsteps origin dest 2;
The checkleap function makes sure that the piece is going to a space a
Squire could move to, then the checknsteps function makes sure it can get
there in exactly two steps.