The Chess Variant Pages
Custom Search

[ 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 ]

Comments/Ratings for a Single Item

EarliestEarlier Reverse Order LaterLatest
This item is a game information page
It belongs to categories: Orthodox chess, 
It was last modified on: 2020-01-30
 By Aurelian  Florea. Apothecary Chess-Modern. Large board variant obtained through tinkering with known games.[All Comments] [Add Comment or Rating]
Aurelian Florea wrote on 2020-05-27 UTC

I had seen the material in the meantime. Thanks. GameCode is a Marvel!...

Aurelian Florea wrote on 2020-05-27 UTC


Hopefully you don't feel to nagged, but I still don't understand how to add a piece in the reserve. So far I got this.

setsystem starpath (!p2) reverse (!p9);
reserve first P;
reserve second p;
allow drops 2;

Fergus Duniho wrote on 2020-05-27 UTC

$starpath is an array of two arrays. This should do:

setsystem starpath ((!p2) (!p9));

You don't need to use the reserve command if you place the Jokers there in your FEN code.

Aurelian Florea wrote on 2020-05-28 UTC

I still get the same error:

ILLEGAL: R a1-d1; J*origin on turn 1:

You have no J to drop with the * operator for move: MOVE:  J*origin.

In the end of pregame I have:

setsystem starpath ((!p2)(!p9));
reserve first J;
reserve second j;
allow drops 2;


in the end of postmove1 I have:

verify == space p2 J;
if > turn 8:
delete p2;
elseif not $answered and == mln $maxmln:
ask "Do you want to insert your joker now?" "Yes" J*origin "No";

There is also the need to check for flags but for now I'd like to understand why I receive this error. Thanks! 


I have deleted the reserve commands. Now it just does nothing.

Fergus Duniho wrote on 2020-05-28 UTC

Perhaps because Shogi has Black move before White, something got mixed up in how drops work, and the first array in $starpath is for the second player. So, switching the two values in the $starpath array fixes this problem.

But then you have a new problem. When you allow multiple moves on the same turn, you have to treat them individually. This normally involves rolling back the moves, then doing one at a time, checking the legality of each move individually before doing the next one. See my code for Extra Move Chess or Marseillais Chess for examples.

Aurelian Florea wrote on 2020-05-28 UTC

Marseillaise chess seems to have an error!

Aurelian Florea wrote on 2020-05-28 UTC

What should I learn from Extramove chess? I see that the premove section has a store command. That means that the initial position is remembered and probably later restored and then actually make the 2 moves after legality checks have been made.

Fergus Duniho wrote on 2020-05-28 UTC

What you should learn from Extra Move Chess is how to program your code to deal with two moves made by the same player on the same turn. While Chess allows Pawn Promotion as two moves without going through this, this is because adding a piece to a space does not change the values of $origin and $dest. However, dropping a piece does. It counts as a complete move just as much as moving a piece on the board.

The first line in Extra Move Chess's Post-Move section is

set mvs explode chr 59 thismove;

This line creates an array of all the moves made. It uses chr 59 to tell the explode function to split the string returned by thismove where semicolons appear.

The next line restores the position to what it was when it was stored in the Pre-Move section.

Some of the stuff that follows is peculiar to Extra Move Chess. The main thing to pay attention to is how it uses the elements of the mvs array to replay each individual move before testing its legality.

If you don't want to program the game as though it were a double move variant, then you could introduce the Joker to the board with an add move. This is the kind of move used in Pawn promotion. It uses the piece notation with a hyphen and a destination. Unlike a regular move, it does not include an origin space.

Fergus Duniho wrote on 2020-05-28 UTC

The alternative to dropping a piece held in hand is what is called in the code freedrops. But allowing this will allow a bunch of illegal moves that would have to be prevented in the code. Also, it changes the value of $dest if it is to a location other than $dest, and that might still require you to handle things as though a double move were being made. One other alternative is to put the rule enforcement code in the Pre-Move sections. This would involve rewriting some things. You would have to extract the moves from thismove and test their legality before they're made. Before they're made, $origin and $dest would not be available.

Aurelian Florea wrote on 2020-05-28 UTC

So any way I go it is a bit complicated.

Now I face an message saying that : A J cannot move from p2 to origin (anywhere origin is).

To be honest, at the beginning I never though programming this game is going to be so tough. I remembered you warning me about it.

For now my mind is all over the place. I think I'll try again tomorrow.

Fergus Duniho wrote on 2020-05-28 UTC

One of the things that can make programming double moves more difficult is the loss of information about the previous move. To help correct that, I have added three new variables called $prevmoved, $prevorigin and $prevdest. These store the previous values of $moved, $origin and $dest respectively. Using these, you could detect whether a Joker has been dropped and test whether the previous move was legal. Here's how it could work.

Instead of using $moved, $origin and $dest in the code for evaluating the main move, use some variables, such as #piece, #from and #to. If the last move was a Joker drop, set these variables to $prevmoved, $prevorigin, and $prevdest. Otherwise, set them to $moved, $origin, and $dest. Evaluate the move. Then if a Joker drop was made, evaluate that.

Aurelian Florea wrote on 2020-05-29 UTC

For entering the block of code that is about the joker insertion I try to use these commands. Why am I wrong? 

verify flag space $origin; 

verify == space p2 J;

Fergus Duniho wrote on 2020-05-29 UTC

space returns what is on a space, which is a piece. I presume you flagged the spaces, not the pieces. So, you want the flag named after the value of $origin.

Aurelian Florea wrote on 2020-05-29 UTC

For now in my pregame section I have relevant to this discussion the following:

setsystem starpath ((!p9)(!p2));
allow drops 2;

And and the end of my premove section there is this code:

verify flag $origin;
verify == space p2 J;
if > turn 8:
delete p2;
elseif not $answered and == mln $maxmln:
ask "Do you want to insert your joker now?" "Yes" J*a1 "No";

How would you do it? I don't have something solid to stand on it seems!

Fergus Duniho wrote on 2020-05-29 UTC

I wouldn't use ask in the Pre-Move section. This should be used after a player has moved, not before. Since the Jokers begin on !p9 and !p2, you want to use those coordinates, not p9 and p2, which do not exist. Prefixing a coordinate with the exclamation mark indicates that labels for that file should not be displayed on the board. This is useful for in-hand areas you drop pieces from Shogi-style. The rest may be okay to include in your Pre-Move section, but there isn't any special need to include it there as opposed to the Post-Move section, where other important code would have to go anyway. When using verify, bear in mind that it exits the function when given a false value. This is okay when no other code follows it than what is shown here.

Fergus Duniho wrote on 2020-05-29 UTC

I would use code like the following in the Post-Move sections. This code is for White.

  if isvisible $origin:
    set piece $moved;
    set from $origin;
    set to $dest;
    set piece $prevmoved;
    set from $prevorigin;
    set to $prevdest;
  // Regular code for enforcing piece movement, but using the variables defined above
  // instead of the system variables.
  if not isvisible $origin:
    if != $moved J:
      die You may not drop any piece other than a Joker.;
    elseif != $dest $prevorigin:
      set pname alias const alias $prevmoved;
      die You may not drop your Joker on any space except the one the #pname just left.
    delete $origin;
    unsetflag $prevorigin;
  elseif onboard !p2:
    if not $answered and == mln $maxmln and <= turn 8 and flag $origin:
      set jmove join "J*" $origin;
      ask "Do you want to insert your Joker now?" "Yes" #jmove "No" "";
    elseif >= turn 8:
      delete !p2;
      remind Joker removed because 8 turns passed without dropping it on the board.
      unsetflag $origin;

Aurelian Florea wrote on 2020-05-30 UTC

To me the code looks great, but after copying it I got at the beginning of the program :

if == thismove null:
say This preset enforces the rules and displays legal moves.;

this error:

Syntax Error on line 2

Misplaced endif within main scope 0.


This is very puzzling to me. Any ideea why this happens?

Fergus Duniho wrote on 2020-05-30 UTC

When that happens, it is usually because something is out of place somewhere else in the code. When it reported the error, it also listed the program. The listing of the program is formatted so that lines are properly indented. So, you should scan the listing for any line that is not indented properly. When I did that, I found a misaligned endif between lines 199 and 200. A little further on, I found a misaligned else between lines 208 and 209. Make sure all your semicolons and colons are in place around those lines.

Aurelian Florea wrote on 2020-05-31 UTC

There were 2 semicolons missing indeed. I have corrected that. But still it never goes as far as to ask the question.

Aurelian Florea wrote on 2020-06-05 UTC


I'm not sure if you've seen my previous comment but the last code you have made doesn't get as far as to ask the question about inserting the joker. I have had a similar problem before. Hopefully you can spare some time this week-end to take a look.

Fergus Duniho wrote on 2020-06-05 UTC

I think you need to remove the line:

unsetflag $prevorigin;

Aurelian Florea wrote on 2020-06-05 UTC

I tried that, it is not it it seems :(!

Fergus Duniho wrote on 2020-06-05 UTC

You still need to remove it, and you have to adapt the code I gave you to Black. While you changed 8 to 12, you did not make any of the other changes that needed to be made for Black. Without those changes made, it is not going to work for Black. Also, the comment I left in the code was a placeholder for code you were supposed to write and include at that spot. It was not meant to be inserted into the code as is.

Aurelian Florea wrote on 2020-06-06 UTC

While working on the changes to the preset modifying it to include the joker drop rule, I have started pondering the idea of renouncing this rule.
The programming for the game has become to bloated and frankly I doubt the need for such a rule anymore.
To replace that the joker would start in the current king's place and the king a rank back. As a consequence the king will lose the special moves but gain a castle ability.
I hope the members of the community could offer an opinion about this change.

Aurelian Florea wrote on 2020-06-06 UTC

In doing that the pros would be :

1. More comprehensive rules.

2. Easier programming

and the cons would be:

1. no more compensation for black's second move disadvantage

25 comments displayed

EarliestEarlier Reverse Order LaterLatest

Permalink to the exact comments currently displayed.