Comments/Ratings for a Single Item
@Fergus,
I have unfortunately uncovered another bug on the preset for this game.
The joker can't move when imitating a pawn, although the moves are properly displayed. Any idea why?
Since it works for displaying legal moves, it's probably because the Pawn functions are only for potential moves, and the Joker is trying to use one of the Pawn functions when making an actual move. Specifically, I think it fails on the line "and empty #1" in the Pawn function, because that space is occupied for an actual move. Some options include changing your rules, rewriting the Pawn functions to handle both potential and actual moves, or using a Joker subroutine for actual moves, which would let you undo the Joker's move before testing it with a function, then redoing it if it is legal.
@Fergus
The way I had thought the game, the joker should, when imitating a pawn, get only the regular power and not promotion rights or double move privileges. And that works best with moving some of the lines in the pawn function to the pawn subroutine. It should be rather easy.
I wouldn't recommend that. That doesn't sound like the correct solution to your problem.
Ok, thanks for the heads up. I'll try to think at something else.
@Fergus
A few weeks ago I have figured out that the joker imitates the pawn in all things which causes the joker moves to not be allowed.
To tackle this issue I have decided to write a Barren_Pawn function that the joker will use when imitating a pawn instead of imitating the regular pawn function. Otherwise things are unchanged. The Barren_Pawn functions are:
def White_Barren_Pawn checkaleap #0 #1 1 0 and empty #1 islower space #1 and or checkaleap #0 #1 1 -1 checkaleap #0 #1 1 1;
def White_Barren_Pawn-Range merge leaps #0 1 0 leaps #0 1 1;
def Black_Barren_Pawn checkaleap #0 #1 -1 0 and empty #1 isupper space #1 and or checkaleap #0 #1 -1 -1 checkaleap #0 #1 -1 1;
def Black_Barren_Pawn-Range merge leaps #0 1 0 leaps #0 1 1;
The piece of code involving the joker imitation is:
if != const alias $moved White_Joker:
if != const alias $moved Pawn:
set last_type_moved const alias $moved;
else:
set last_type_moved White_Barren_Pawn;
endif;
endif;
and for black:
if != const alias $moved Black_Joker:
if != const alias $moved Pawn:
set last_type_moved const alias $moved;
else:
set last_type_moved Black_Barren_Pawn;
endif;
endif;
I thought it should easily work. Unfortunately it does not. Any idea why that is?

Is that minus sign in Pawn-Range intended, or is it a typo for an underscore?
Is that minus sign in Pawn-Range intended, or is it a typo for an underscore?
It's a hyphen, not a minus sign, and it is not a typo.
It doesn't work, because you are testing the codename of the piece, but Pawn is not the codename for any piece. It is the display name for the pieces with the codenames of Black_Pawn and White_Pawn.
I have corrected the post move code to:
if != const alias $moved White_Joker:
if != const alias $moved White_Pawn:
set last_type_moved const alias $moved;
else:
set last_type_moved Black_Barren_Pawn;
endif;
endif;
and similar for black. This code works.
But the Barren_Pawn worked fine when I had done only the move part of the pawn's powers but now I have added the capture part and nothing is legal anymore. Please help if you may! The code in question is:
def Black_Barren_Pawn
checkaleap #0 #1 0 -1 and cond empty #0 not capture empty #1
or checkleap #0 #1 -1 -1 or checkleap #0 #1 1 -1
and cond empty #0 capture isupper space #1;
The first thing it does is require that the move is a capture. If it is not a capture, it will not proceed any further.
I'm confused about what you want to say. Isn't it that : and cond empty #0 capture isupper space #1; does exactly that, capture for actual moves, and isupper space #1 checks for a potential victim in potential moves? Where am I wrong?
I'm confused about what you want to say. Isn't it that : and cond empty #0 capture isupper space #1; does exactly that, capture for actual moves, and isupper space #1 checks for a potential victim in potential moves? Where am I wrong?
That's not the issue. The issue is that and has only one value. With only one value, it is a breaking and, which means that it will immediately exit the function and return false if the value it receives is false. See the "Breaking Logic" section in the tutorial on the fairychess include file for details.
I have corrected the mistake and now it goes like this:
def White_Barren_Pawn
checkaleap #0 #1 0 1 and cond empty #0 not capture empty #1
or and checkaleap #0 #1 -1 1 or checkaleap #0 #1 1 1
cond empty #0 capture islower space #1;
def White_Barren_Pawn-Range merge leaps #0 1 0 leaps #0 1 1;
def Black_Barren_Pawn
checkaleap #0 #1 0 -1 and cond empty #0 not capture empty #1
or and checkaleap #0 #1 -1 -1 or checkaleap #0 #1 1 -1
cond empty #0 capture isupper space #1;
But during my tests I came across the fact that a joker imitating a barren_pawn does not have the ability to capture another joker (although it is fine when capturing a knight).
I think this would work better. I moved an or and reformatted it to show the logic better.
def White_Barren_Pawn
checkaleap #0 #1 0 1
and cond empty #0 not capture empty #1
or and
or checkaleap #0 #1 -1 1 checkaleap #0 #1 1 1
cond empty #0 capture islower space #1;
def Black_Barren_Pawn
checkaleap #0 #1 0 -1
and cond empty #0 not capture empty #1
or and
or checkaleap #0 #1 -1 -1 checkaleap #0 #1 1 -1
cond empty #0 capture isupper space #1;
It works well. I hope there are no more bugs. Thanks Fergus!
@HG, Hello, The interactive diagram on this page puts in the initial position an extra black joker outside of those defined. Why is this happening?

I suppose you need a symmetry=none line in the diagram definition. It is probably reflecting the other Joker now.
@HG, ... But it has introduced another problem. Now the shuffling of pieces is not simtrical anymore :(!
@HG : And I could not find a solution on my own :(!

I guess the current diagram script cannot do this, because the specified symmetry is applied both to the shuffling and to the setup. You seem to want a point-symmetrical setup, (symmetry=rotate) but then a line-symmetric shuffle (symmetry=mirror).

This night the following occurred to me: I normally write a Diagram definition by first specifying all parameters, and then all pieces. Although some parameters (such as the board size) must be set before placing any pieces, in general there is no need for this ordering, and parameter definitions and piece definitions can be mixed in any order. Furthermore, it is not an offense to specify the same parameter multiple times with different value; each definition simply replaces any previous value, so that the value from the last definition prevails.
You could therefore try the following: start with a line symmetry=none amongst the parameter settings. Then specify all pieces with their locations. Because at the time of their processing the symmetry is set to none, it will not automatically place any mirror images, and you specify the squares of both white and black pieces in any way you want. After defining all pieces, you add a line symmetry=mirror . This will alter the symmetry spec, but this new spec will not be used during setup, which is already done. It will be used during shuffling, though, which occurs after the entire Diagram definition is read.
Thanks so much HG. very cool tool you have made!
25 comments displayed
Permalink to the exact comments currently displayed.
@ Fergus,
I have found the mistake.
This piece of code was missing and adding it has solved the problem.
if == moved K:
unsetflag f2;
set Kpos $dest;
endif;