Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

GAME Code help[Subject Thread] [Add Response]
🕸Fergus Duniho wrote on Thu, Jun 1, 2017 11:26 AM UTC:

The Alfaerie: Many set is one I have never used and do not recommend the use of. Consequently, I have never tried to program around its limitations. I recommend creating your own set, but if you don't want to do that, then you might try using one of the automatic sets, which name pieces after file names.

It has occured to me since writing this that you could name your functions after aliases instead of the actual piece labels and be sure to use the aliases and not the actual labels when calling the functions.

def G checkride #0 #1 1 0 or checkleap #0 #1 1 1;
def GL merge rays #0 1 0 leaps #0 1 1;

I understand that the #0 and #1 stand for the initial square moved and final square moved, but I don't understand how the 1's and 0's after those work exactly, though I have been able to fudge the results I want with those.

The other ones and zeros are actual ones and zeros, not variables. They are arguments to the function. Your definition of G checks whether the piece moves as a Dragon King. "checkleap #0 #1 1 1" checks whether a piece can make a one-space diagonal move. This can also be done by calling checkaleap up to four times, like so:

checkaleap #0 #1 1 1 or checkaleap #0 #1 1 -1 or checkaleap #0 #1 -1 1 or checkaleap #0 #1 -1 -1

In checkaleap, the first number is how many files a piece moves in its leap, and the second number is how many ranks. In checkleap, the order and signs of the numbers do not matter. Instead, the two values are used in whichever order and whichever positive or negatives values are most applicable to the actual move. This allows the values of 1 and 1 to describe any one-space diagonal move.

For the leaps function, the order of the numbers and their signs also do not matter. From a single pair of values, all possible combinations of orders and negative or positive values are calculated. Up to eight combinations are possible. For example, "leaps #0 1 2" would return up to eight legal moves for a Knight. But when the values are the same, or when one is zero, this cuts the number in half.

"checkride #0 #1 1 0" checks whether it moves as a Rook, which makes a riding move through a series of steps in a direction that moves one space at a time along a single rank or file. The same thing could be checked with four checkaride functions, like so:

checkaride #0 #1 1 0 or checkaride #0 #1 -1 0 or checkaride #0 #1 0 1 or checkaride #0 #1 0 -1

In checkaride, the first number is how many files the piece moves on each leap, and the second is how many ranks it moves on each leap. In checkride, the order of the numbers do not matter, and their signs do not matter. It will use them in whichever order and arrangement of negative and positives values best fits the actual move. This allows "1 0" or "0 1" to be used to describe movement along a single dimension of the board.

For the rays function, the order of the numbers and their signs also do not matter. From a single pair of values, all possible combinations of orders and negative or positive values are calculated.