Comments/Ratings for a Single Item
In the light of recent disuctions in the sister game, I have updated the rules for this game and brushed up a bit the article.
Also the preset allows the game to be played here.
@Thor
I had sent you an invitation with the new preset.
@Fergus,
I have copied the code from Apothecary-Modern here, and when I test the preset it seems fine, but when I try to move in an ongoing game of Apothecary Classic, I receive the error saying I've made special moves out of check.
Any idea why?
It sounds like you modified the code of an ongoing game in a way that retroactively made a past move illegal.
@Fergus,
I have moved the buggy code from the presets named apothecary-classic and apothecary-modern to the apothecary2working and apothecary1working.
The code I had mentioned before:
if flag f2:
if moved == K:
move $dest $origin; // Temporarily undo King move
if sub checked $origin:
if not or checkleap $origin $dest 1 0 checkleap $origin $dest 1 1:
die A King may not use the special moves out of check.;
endif;
endif;
move $origin $dest;
endif;
endif;
introduces a bug. Sometimes the message A King may not use the special moves out of check. is displayed seemingly randomly when non-king pieces are moved. That I had checked with the play at same location feature.
Have you any idea on how to fix this bug?

Well, if I look at your page source, I see this:
<div class="idiagram"> files=10 ranks=12 holdingsType=1 promoZone=3 promoChoice=!P*N*B*L*E*R2*J2*Q3*C3*A3 graphicsDir=../graphics.dir/alfaerie/ whitePrefix=w blackPrefix=b graphicsType=gif squareSize=54 symmetry=none pawn:p:ifmnDfmWfceF:pawn:a4,b4,c4,d4,e4,f4,g4,h4,i4,j4,,a9,b9,c9,d9,e9,f9,g9,h9,i9,j9 rook::::, queen::::, bishop:b:B:bishop:, knight:n:NmZ:knight:,:1 mamluk:l:WL:camel:,:1 siege elephant:e:FAH:elephant:, joker:j:fI:fool:, Chancellor:c:RN:chancellor:, archbishop:a:BN:cardinal:, </div>
You should also see that when you edit your comment in source-code mode. (Switching the submission editor to WYSIWYG mode and then back to source code destroys the diagram, don't do it!)
Most of it looks OK, but except for the Pawns, the lists of squares where the pieces should be placed are all empty. You should have something like a2,j2,,a11,j11 for the Rooks etc., but you just have a single comma. I also see no King amongst the pieces. And in the promoChoice string you probably intend to suffix Q, C, A with '1' rather than '3', if you only allow those on the final rank. (Since you have promoZone=3, '3' would be default anyway, and would not have to be specified.)
Also, you defined the piece IDs as lower case, but in the promoChoice string you then refer to them with upper case. There isn't really any reason to define the ID for pieces other than Knight, as by default it would take the (capitalized) first character of the name.
HG,
About the king: It does not castle bun while virgin it may leap one rank back using a knight or camel jump. I am thinking that in xbetza is : KimbsLimbsN. Is it correct?
The pieces are missing beacuse they should be added by shuffling. But for now I can;t do this. It probably should be treated as a particular case as the algorithm for placing piece from this game is rather weird, but you had said it may be done by java script.
Also I want to see the brouhaha code and the 960 code.

The Diagram does have a shuffle option now. But to make that work you should first place the pieces in some 'reference position', and then indicate in a shuffle option which piece types you want to permute. (It can then see the set of squares that should be involved in the shuffle.) Depending on whether the King has a castling move defined on it, the shuffle will respect its placement between the corner pieces during the shuffle, or not. In your case you have no castling, and there would be no restriction to the King placement.
In Chess960 the reference position would be FIDE; from this it would then know that the castling partners are Rooks, and that the King must remain between the Rooks. BTW, the Diagram does not implement Fischer castling; no way has been devised yet to indicate that in XBetza; the On notation would mean something else. Perhaps OX ? But as far as the shuffling is concerned, you could say shuffle=N!BRQK, where the exclamation point before the B indicates Bishops should be equally distributed over shades. When you ask it to do impossible things the results will be undefined.
I don't know whether this shuffle option satisfies your needs. A straightforward enhancement of it could be to allow multiple 'shuffle groups' (say comma separated in the shuffle option), where it would then apply the same shuffling as it does now to each group independently. (They had better be non-overlapping groups then, or the results would get statistical bias.)
And yes, your King move seems correct. But you should be able to see that in the XBetza sandbox, when you ask for the move diagram.
To see diagram source in a comment I usually click the 'View' link at the bottom of the comment to see it in isolation (so that I don't have to look for it on a page that contains lots of other stuff), and ask my browser to show the page source. There will still be a lot of stuff before it for the menu bar, and all the adds, but you can always use the browser search function to look for 'idiagram'.
HG,
1. I still have not figured out how to make the squares, brouhaha
2. It may be a nice feature to display the brouhaha squares in a different colour
3.I don't think the shuffling works in this particular case (please read the article) but probably a javascript code is possible to do. Unfortuneatly I don't know Java script so if you can help me here I'd really apreciate it.

1. I still have not figured out how to make the squares, brouhaha
Just define a first piece with name 'hole' (the ID, move and image fields will be ignored), and a list of 'starting squares' where you want the holes to be. Then you also specify a piece to start at one of those squares. All holes act as brouhaha squares, also during the game: you can place pieces on them, and when you then move them away they revert to black.
2. It may be a nice feature to display the brouhaha squares in a different colour
I will think about it. Perhaps dark grey.
3.I don't think the shuffling works in this particular case (please read the article) but probably a javascript code is possible to do. Unfortuneatly I don't know Java script so if you can help me here I'd really apreciate it.
Well, this sounds more like placement chess with some restrictions than like shuffling. The logcal solution would be to put all the pieces in hand (except those that have fixed location, like Kings and Rooks). For easy placement just display the piece table permanently next to the board. You can do that by defining in the diagram parameters satellite=apothecary , and then somewhere on your page put a HTML element <table id="apothecaryTable"></table> . The Diagram script will then put the piece table there, rather than collapsible under the diagram, and people can directly drag the pieces to the Diagram.
HG,
I'm not sure what placement chess is.
I was wondering if the placement of the pieces may be done automatically. Can a javascript be written to do this. and after each restart another legitimate initial position can be generated.
@Fergus
I have tried to implement the ban on special moves while the virgin king is in check. I'm far from the result.
Could you take a look at the link below?
This should be handled in the Apothecary_King function and in the Apothecary_King subroutine, not externally. Furthermore, the subroutine should not call the function. Each one should handle this independently from the other.
I have separated the 2 codes but never are the special moves availeble. I'm not sure about what to do!
The subroutine should undo the King's move before checking whether it is in check. If the move is legal, then it should redo it. The function does not need to undo and redo the King's move, but it should make sure the King is not in check before allowing the special moves. Also, each should handle the regular moves before checking whether the King is in check. Your current subroutine is very wasteful, because it will check whether the King is in check every single time.
You are saying the the checked subroutine must be used inside the function?
Like that:
def Apothecary_King
checkleap #0 #1 1 3
or checkleap #0 #1 1 2
and match rankname #1 1 10
and flag #0
and not sub checked $origin
or checkleap #0 #1 1 0
or checkleap #0 #1 1 1;
because this does not work.
$origin should not be included in the function definition. It may be used as an argument when calling a function or subroutine, but it should not be included in the definition of one. You should check the flag before calling the checked subroutine, because that will minimize the use of the subroutine. The same goes for checking the rank of the destination. Always do less expensive operations before more expensive operations, because that will minimize the need to do the most expensive operations.
I have made the distinction between the function and the subroutine. But I still could not make work as expected.
def Apothecary_King
checkleap #0 #1 1 3
or checkleap #0 #1 1 2
and not sub checked #0
and match rankname #1 1 10
and flag #0
or checkleap #0 #1 1 0
or checkleap #0 #1 1 1;
sub Apothecary_King from to:
if checkleap #from #to 1 1 or checkleap #from #to 1 0:
return true;
endif;
move #to #from;
if checkleap #from #to 1 3
or checkleap #from #to 1 2
and match rankname #to 1 10
and flag #from :
if sub checked #from:
die You may not perform the special moves out of check.;
endif;
else:
move #from #to;
return true;
endif;
endsub;
The function looks fine. In the subroutine, you should remove the else.
Also, add "return false;" to the very end of the subroutine.
The new sub looks like this:
sub Apothecary_King from to:
if checkleap #from #to 1 1 or checkleap #from #to 1 0:
return true;
endif;
move #to #from;
if checkleap #from #to 1 3
or checkleap #from #to 1 2
and match rankname #to 1 10
and flag #from :
if not sub checked #from:
move #from #to;
return true;
else die You may not perform the special moves out of check.;
endif;
endif;
return false;
endsub;
When trying to use regular moves out of check, I get the error "you cannot move into check.". This happens with or without the else part.
I didn't say to get rid of the else clause. I said to get rid of the else. Just the else. A single line of code.
It still gives the error: "you may not move into check".
25 comments displayed
Permalink to the exact comments currently displayed.
It works!... I'm so happy!...