Comments/Ratings for a Single Item
@Fergus: In the routine below the variable 'sqr' stays 0 for all iterations. Only when I deleted the comma ("for (sqr piece) $space;") it runs through the square labels. Yet the GAME code manual suggest a comma should be present.
(And thanks for fixing the dash problem; I would never have found that.)
Yet another question: is there an elegant way to convert internal rank and file number to the square label? For games that need symmetric shuffling I first shuffle the white pieces, and then copy the white setup (color-flipped) to the black camp, and for that I have to derive the label of the mirror square. This is now done by a pretty complex calculation. Which only works if rank labeling is a consecutive range of integers.
@Aurelian: The FEN for your start position has one dash too many at the start. Otherwise it should work now. (At least the shuffling.)
In the routine below the variable 'sqr' stays 0 for all iterations. Only when I deleted the comma ("for (sqr piece) $space;") it runs through the square labels. Yet the GAME code manual suggest a comma should be present.
The Developer's Guide was wrong. I have corrected it. It uses spaces as separators, and when I used a comma, it added the comma to the variable name, so that this code worked:
foreach (key, var) spaces:
echo #key, #var;
next;
But this code did not:
foreach (key, var) spaces:
echo #key #var;
next;
(And thanks for fixing the dash problem; I would never have found that.)
It's important to remember that it was a minus sign, not a dash. When you use the # prefix before a variable name, it rewrites your code by replacing your variable with its value. Because it rewrote your code with a minus sign, your line of code was now trying to do subtraction. This threw a monkey wrench into your code in a way that a mere dash – which would be a meaningless string that was wider than a minus sign – would not have. Inserting the value of variables in this way is mainly intended for using variables with commands that do not process expressions (at all or for a certain argument). Within expressions, it is usually safer to use the var operator, which simply returns the variable value without rewriting your code. I believe functions are now an exception to this, since the following code prints 13, not 17:
set a 8;
def test + 9 #a;
set a 4;
print fn test;
@HG, It seems all well to me so far but the pictures used are the ones from the alfaerie many where the letters in use are from the interactive diagram. So it is difficult to read out. How do I fix this?
Two possibilities:
1) Change the piece IDs in the description of the Interactive Diagram before you paste it into the Play-Test Applet.
2) Edit the GAME code generated by the Applet in order to change the IDs of the pieces you want changed. Piece labels occur in the function definitions and in the arrays behind the legdefs array with step descriptions, in the Pre-Game code.
@HG, Yes, I was thinking about this!
6 comments displayed
Permalink to the exact comments currently displayed.
Here is the fixed subroutine:
The actual fix was changing #piece to var piece in the conditional if match var piece #toshuffle:. There are subtle differences between these two ways of getting the values of variables. The way you were doing it embedded it into the line during pre-processing, and the problem with doing that was that its first value was -, which is also an operator. Changing it to var piece made sure that it treated the value as a string at the proper time and not as the minus operator.
I changed another line to use the color operator, because this might be a better way of doing what you want. This returns the color index associated with the space. Looking at the color values, I figured that the number 1 was being used for the dark squares.