Comments/Ratings for a Single Item
- 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;
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.
@Fergus,
Why in the castle subroutine in fairychess.txt include file the line unsetflag #RPOS; is commented?
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,
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?
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 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.
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.
@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?
No ideea I'll Try it!
@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.
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;
With your piece of code I have tested my idea and made it work as intended. Thanks once again, Fergus!
@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).
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.
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!
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).
HG, Have you took any time to take a look on the initial position randomization issue?
@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.
When I tried it by itself, it did loop through the board. Perhaps something in the outer context is affecting your code.
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".
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?
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.
25 comments displayed
Permalink to the exact comments currently displayed.
Test. I keep getting the error message, "There is no comment to post."