The Chess Variant Pages
Custom Search




[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Latest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Comments/Ratings for a Single Item

Later Reverse Order EarlierEarliest
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-Classic. Large board variant obtained through tinkering with known games.[All Comments] [Add Comment or Rating]
Aurelian Florea wrote on 2020-07-22 UTC

It works well. I hope there are no more bugs. Thanks Fergus!


Fergus Duniho wrote on 2020-07-22 UTC

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;

Aurelian Florea wrote on 2020-07-22 UTC

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).


Fergus Duniho wrote on 2020-07-22 UTC

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.


Aurelian Florea wrote on 2020-07-22 UTC

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?


Fergus Duniho wrote on 2020-07-21 UTC

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.


Aurelian Florea wrote on 2020-07-21 UTC

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;


Fergus Duniho wrote on 2020-07-21 UTC

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.


Fergus Duniho wrote on 2020-07-21 UTC

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.


H. G. Muller wrote on 2020-07-21 UTC

Is that minus sign in Pawn-Range intended, or is it a typo for an underscore?


Aurelian Florea wrote on 2020-07-21 UTC

@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?


Aurelian Florea wrote on 2020-07-06 UTC

Ok, thanks for the heads up. I'll try to think at something else.


Fergus Duniho wrote on 2020-07-06 UTC

I wouldn't recommend that. That doesn't sound like the correct solution to your problem.


Aurelian Florea wrote on 2020-07-06 UTC

@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.


Fergus Duniho wrote on 2020-07-03 UTC

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.


Aurelian Florea wrote on 2020-07-03 UTC

@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?

 


Aurelian Florea wrote on 2020-07-02 UTC

@ 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;


Aurelian Florea wrote on 2020-07-01 UTC

It still gives the error:  "you may not move into check".


Fergus Duniho wrote on 2020-07-01 UTC

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.


Aurelian Florea wrote on 2020-07-01 UTC

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.


Fergus Duniho wrote on 2020-06-30 UTC

Also, add "return false;" to the very end of the subroutine.


Fergus Duniho wrote on 2020-06-30 UTC

The function looks fine. In the subroutine, you should remove the else.


Aurelian Florea wrote on 2020-06-30 UTC

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;


Fergus Duniho wrote on 2020-06-30 UTC

$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.


Aurelian Florea wrote on 2020-06-30 UTC

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.


25 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.