Comments/Ratings for a Single Item
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, 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?
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;
@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.)
Here is the fixed subroutine:
sub GetSquares toshuffle:
my sqr piece;
// determine the squares the pieces in the given set are on.
// the result is left in 3 global arrays:
set left array; // on left board half
set light array; // as well as sorted by shade
set dark array;
printr $space;
for (sqr, piece) $space:
print . iter . #piece #sqr;
if match var piece #toshuffle:
if < * 2 file #sqr lastfile: // left half
push left #sqr;
endif;
if == color #sqr 1: // distinguish by shade
push dark #sqr;
else:
push light #sqr;
endif;
endif;
next;
print "got it";
endsub;
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.
When I clicked on that, I saw a listing of all the spaces. So, I presume it is working.
No, that just shows the printr $space before the loop worked. After that list of spaces it prints "iter0" in the first and only iteration of the loop.
If things worked, you would not see anything printed; You would just see the diagram of the shuffled starting position.
This routine is in the shuffle.txt file included in the preset Aurelian posted the link to 5 postings ago in this subject thread.
When I clicked on that, I saw a listing of all the spaces. So, I presume it is working.
Once you have shuffled the pieces, are you storing the results of the shuffling in a constant for later reuse?
There isn't that much context; it is in a subroutine, and sqr and piece are 'my' variables, which should pretty much decouple it from the remaining code:
sub GetSquares toshuffle: my sqr piece; // determine the squares the pieces in the given set are on. // the result is left in 3 global arrays: set left array; // on left board half set light array; // as well as sorted by shade set dark array; printr $space; for (sqr, piece) $space: print . iter . #piece #sqr; if match #piece #toshuffle: if < * 2 file #sqr lastfile: // left half push left #sqr; endif; if & 1 + file #sqr rank #sqr: // distinguish by shade push dark #sqr; else: push light #sqr; endif; endif; next; print "got it"; endsub;
This routine is in the shuffle.txt file included in the preset Aurelian posted the link to 5 postings ago in this subject thread. That preset calls the routine ShuffleSetup (at the very bottom of the Pre-Game section), which eventually calls this routine. If you click that link it directly tries to execute the preset, which immediately exits after printing the $space array, and "iter0". It never gets to the "got it".
When I tried it by itself, it did loop through the board. Perhaps something in the outer context is affecting your code.
@Fergus: I don't understand what is wrong with the following GAME code:
for (sqr, piece) $space: print . iter . #piece #sqr; if match #piece #toshuffle: if < * 2 file #sqr lastfile: // left half push left #sqr; endif; if & 1 + file #sqr rank #sqr: // distinguish by shade push dark #sqr; else: push light #sqr; endif; endif; next; print "got it";
I would have expected it to loop over the board. But instead it prints "iter0" and then exits. If I do a "printr $space" just before it, it does print the board as expected.
HG, Have you took any time to take a look on the initial position randomization issue?
1) It seems the checkbox "Do not include moves in code" is not ticked.
2) Something is wrong with the shuffling; I still have to figure out what. When I delete the last line of the Pre-Game code ("gosub ShuffleSetup;") the preset seems to work (but without shuffling, of course).
The result of one of my 3 games is here :
https://www.chessvariants.com/play/pbm/play.php?game=Grand+Apothecary+Chess+1&settings=Applet
although it seems I have done something wrong as I don't get normal results. It just says to report any bugs to you HG!
You already made an Interactive Diagram that does the Pawn move and the castling in the way you want, right? All you have to do is paste the description of that diagram (without any HTML tags) into the Play-Test Applet, (where it says "paste an existing diagram"), and click the 'Game code' button.
@HG Muller
@Aurelian: Just out of curiosity: what happens when you use the Play-Test Applet to convert the Interactive Diagram you made to GAME code? Does the castling work as intended then?
I'm not sure I know how to do this. I have read this:
https://www.chessvariants.com/invention/game-code-generation
but I did not understood how to do the weird castling, or something that needs doing in game code like initial pawn pushes. (the * in Xbetza).
With your piece of code I have tested my idea and made it work as intended. Thanks once again, Fergus!
I still need to understand how to delete a value from an array in order to remove the necessary value from wcastle or bcastle.
You can unset an array element if you know its key. For example:
set ra array a b c d e f g h i j k l m n o p q r;
unset ra.4; // removes e from array
But what if you just know the element you want to delete and not its key? I have now added a diff operator to return an array difference. When an argument isn't already an array, it gets turned into a single element array. So, this code removes j1 from wcastle.
set wcastle d1 c1 j1 k1;
set wcastle diff #wcastle j1;
@Fergus,
I still need to understand how to delete a value from an array in order to remove the necessary value from wcastle or bcastle.
No ideea I'll Try it!
@Aurelian: Just out of curiosity: what happens when you use the Play-Test Applet to convert the Interactive Diagram you made to GAME code? Does the castling work as intended then?
I do not understand why after I move the rook I can castle with the cannon on the field that was supposed to be used only for the rook.
So far, you have not made it clear that the King moves to a different space when castling with each piece. The rules you have underneath the game do not even mention castling. The castle subroutine was not written with such a rule in mind. You might be able to make it work by adjusting the values of bcastle and wcastle after a Rook moves.
I think I haven't explained that properly but only one castle is aloud.
Castling is allowed only once, which I understand, but what you say next doesn't fit with you trying to say that. Are you trying to say that the King has only once space it can go to when castling with a certain piece?
Regarding your preset, I don't understand why you are using four colors for checkering the board. Also, the dark blue squares do not contrast well with the color used for highlighting legal moves, which makes it hard to see legal moves highlighted on those squares. Additionally, your rules could use images of the pieces, so that someone looking at a piece on the board can more easily tell how it moves. Remember to use the shortcodes for displaying pieces, so that the piece images below match those on the board no matter what piece set is used.
@Fergus Then I do not understand why after I move the rook I can castle with the cannon on the field that was supposed to be used only for the rook. I think I haven't explained that properly but only one castle is aloud. This is not free castling. So this is why I asked about wcastle and bcastle.
What I still need to do is delete a variable from wcastle or bcastle as the rook gets moved.
That shouldn't be necessary, as other factors will determine that future castling moves are illegal without doing this.
How do I delete a value from an array?
Once the King has castled, it might be a bit of an optimization if you set wcastle or bcastle to an empty array, but it shouldn't be necessary.
@Fergus,
I am almost done with the castling. It was not that hard. I have left the normal stalemated subroutine which took care properly of the moves display. Also I am handling the flag sets and unsets properly as far as I can see. What I still need to do is delete a variable from wcastle or bcastle as the rook gets moved. How do I delete a value from an array?
Why in the castle subroutine in fairychess.txt include file the line unsetflag #RPOS; is commented?
I suppose it could be uncommented if you wanted to be thorough, but it isn't necessary to prevent illegal castling. Once the King has moved, the space it moves from and the space it moves to both get unflagged, and every space the King moves to gets unflagged. So, no matter what, the King is still unable to castle. As long as the King can't castle, nothing can castle with the King. So, leaving a flag on the Rook's original space doesn't change anything critical to the game.
@Fergus,
Why in the castle subroutine in fairychess.txt include file the line unsetflag #RPOS; is commented?
I think I accidentally deleted a comment while deleting some test comments.
1.The castling moves are not shown although they work.
The code for this goes in the stalemated subroutine, and here is what you have in that subroutine:
// Castling code removed, since Apothecary Chess does not include castling.
So you need to add some code for it there. You can probably borrow some from the one in the fairychess include file. I'm not sure if it will require any modification. Try it without modification first and see how it works.
- The long cannon castle is not done entirely although the king moves correctly.
You don't seem to be unflagging spaces properly. I confirmed that you left the Rook's space unflagged by moving the Rook back after moving it and then castling with it. When the Rook's space remains flagged, you will not be able to castle with the Cannon. You should do as I do in Chess, which is to unflag every space moved to or from. The code used in Chess is
unsetflag $origin $dest;
Test. I keep getting the error message, "There is no comment to post."
I have repeated all my tests. The same two problems appear.
set wcastle d1 c1 j1 k1; set bcastle d12 c12 j12 k12;
From these, I gather that the King lies somewhere between d and j.
setflag a1 b1 k1 l1; setflag a12 b12 k12 l12;
But here, nothing is flagged between d and j. Make sure to flag every single piece that can castle, including the King.
I have forgotten about that:
Can you give me a link to the preset you're working on?
@Fergus, Now I am trying to make the castling work.
The king is supposed to be able to castle with a rook by moving 3 spaces towards it or with a cannon by moving 4 spaces towards it, Usual conditions apply. I have used the following flags and variables:
set wcastle d1 c1 j1 k1; set bcastle d12 c12 j12 k12; setflag a1 b1 k1 l1; setflag a12 b12 k12 l12;
I have 2 problems. 1.The castling moves are not shown although they work. 2. The long cannon castle is not done entirely although the king moves correctly.
@Fergus,
Brilliant, it works and I understood them well enough to be able to make even other pieces.
Since Markdown altered your code by removing the multiplication operators, and HTML interprets the less than sign as the beginning of a tag, I am responding in Text. Here is your code for the Lyon: def Lyon fn (checkride #0 #1 1 0 and empty #0) where #0 * 2 sign - file #1 file #0 * 2 sign - rank #1 rank #0 #1 and not fn Knight #0 #1 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; To rule out regular Rook moves, this should fix it. This produced the correct pattern on an empty 8x8 board with e4 as the origin and also when I blocked the diagonal move at f5. def Lyon checkaride #ts #1 0 sign #rd or checkaride #ts #1 sign #fd 0 and checkride #0 #ts 1 1 and empty #ts =ts where #0 * 2 sign #fd * 2 sign #rd and match 2 abs #fd abs #rd =fd - file #1 file #0 =rd - rank #1 rank #0 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; Instead of using a lambda function, this assigns values to variables that get reused. These are rd for rank distance, fd for file distance, and ts for turning space. After calculating fd and rd, it makes sure that one of them has an absolute value of 2. It then uses them to calculate ts. After checking that ts is empty, it checks that a diagonal move from #0 to #ts is legal, and it then uses the value of fd or rd with checkaride for checking a Rook move in a specific direction from #ts to #1. It first checks for a Rook move along the file of ts. If that returns false, it then checks for a Rook move along the rank of ts. When I tried checkride #ts 1 1 0, it gave inaccurate results. The following code gave the right results on an empty board, but it gave false positives when I blocked it on f5. def Lyon fn (checkride #0 #1 1 0 and empty #0) where #0 * 2 sign - file #1 file #0 * 2 sign - rank #1 rank #0 #1 and not fn Knight #0 #1 and not checkride #0 #1 1 0 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; I will let you figure out how to fix the Tiger, since you should have more of a clue now.
@Fergus
I am trying to write the game code for 2 new pieces I want for my newest chess variants. The first, a bent rider, called the lion should move like a bishop for 2 squares and then towards outside like a rook. It may also move like a dabbabah. I have written the code bellow that has the problem that allows the final rook moves without checking for the first bishop part of the move. Please take a look:
def Lyon
fn (checkride #0 #1 1 0 and empty #0)
where #0 2 sign - file #1 file #0 2 sign - rank #1 rank #0 #1
and not fn Knight #0 #1
or and checkride #0 #1 1 1 <= distance #0 #1 2
or fn Dabbabah #0 #1;
The second, it is also a bent rider, called the tiger should move like a rook for 3 squares and then towards outside like a bishop. It may also move like an alfil. In the same way as before the bishop moves are allowed by my code whitout checking the rook ride. Code so far:
def Tiger
fn (checkride #0 #1 1 1 and empty #0)
where #0 0 * 3 sign - rank #1 rank #0 #1
or fn (checkride #0 #1 1 1 and empty #0)
where #0 * 3 sign - file #1 file #0 0 #1
and not fn Knight #0 #1
or and checkride #0 #1 1 0 <= distance #0 #1 3
or fn Elephant #0 #1;
I could not find code that block the ride in the first part.
In the following is what I did for images and names for this game. I had tried a diagram representation. Unfortunately the 50x50 pixels of the images need to be split in a 9x9 grid leaving little room for things to happen in one grid cell. That is because the longest path mover moves 43&41 and some bent riders bend after the 3rd step. The excepting for that is the joker. The joker is represented by a big J. That got me thinking about making instead images with 2 letters from the English alphabet. What do you think about this? Also if you have any suggestion on how to improve the images I'm listening gladly. I am not talented at this nor imaginative.
Just the Bishop.
The rook.
The queen.
The king.
The pawn.
The berolina.
The knightrider.
The chinesse cannon.
The joker(imitator).
The vulture (a 41&43 falcon).
The knight of this game(NmHmA).
The wizard(FL).
The cahmpion (WAD).
The sangoma (BZ).
The dragon (a ferz then rook).
The griffin (a wazir then bishop).
The Cyclops. A rook3 then bishop that can also do an alfil jump.
The Giant. A bishop2 then rook that can also do an dabbabah jump.
Thanks for reading all this! I await your reactions.
I could not draw the pieces in question (Kirin and phoenix) so if someone is willing to help me I'd be extremely grateful.
Greg, I meant representing the birds, not symbolic representation.
OK, sorry
I think Kirin and Phoenix are perfect names. I like to stick with what is established. Typically, they are represented with:
I also have or can easily make an RNN
EDIT: I do have a chancellor-rider:
I play Chu Shogi often enough. I knew about them. But it seemed to me that it is a good solution. This is because mythical birds seem to go well with bent riders. Should you have a better suggestion, I'm listening.
Jean-Louis, I know what the things are, but I'm not sure about a simple representation as in piece icons.
By the way, both Kirin and Phoenix have an accepted usage from Chu Shogi, it would be a pity to assign them other moves.
Kirin= FD Phoenix= WA
Aurelian you can find them on Wikipedia is that is your question.
The Kirin/Kyrin, or Qilin, is a chinese/japanese monster (haven't you ever drunk a Kirin beer?). Some think that this monster could have been inspired by a giraffe seen by early Chinese navigators.
Like the Aanca/Anka/Anqa could have been inspired by the Aepyornis of Madagascar. The Phoenix is also a monster giant bird, a kind of Greek version of the Persian Anqa. Again, a different beast than the Gryphon/Griffin whatever Murray said :=)
Any idea how a Kirin or Phoenix should look like?
Which images should I use for the Phoenix and the Kyrin. Can anyone help me with drawing and uploading the pictures as I don't have any skills with the draw part and I do not have upload rights?
Phoenix and Kirin it is then!
I dunno why but I'll name them Kyrin and Phoenix respectively
Probably because they remind me of the Chu Shogi pieces with the same name fsr
Hello,
I am in the process of creating three larger version of apothecary chess. This is one of them - apothecary chess modern.
The purpose of this comment is to get help from the community naming and drawing the pieces.
In the previous comment on this thread I have made a interactive diagram with some preliminary names and pictures from what I could find. They are not very good so do not mind them to much.
In the following I'll name the properties of the new pieces and I expect from who may help a name and a description for the picture.
A piece that moves 2 squares like a bishop and may stop here or in the intermediate square and continues like a rook toward outside. And it may also leap like a dabbabah.
A pieces that moves 3 squares like a rook and may stop here or in the intermediate square and then toward outside like a bishop. And it may also leap like an alfil.
56 comments displayed
Permalink to the exact comments currently displayed.
@HG, Yes, I was thinking about this!