Check out Glinski's Hexagonal Chess, our featured variant for May, 2024.


[ 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

LatestLater Reverse Order Earlier
How to Enforce Rules in Game Courier. A tutorial on programming a rule-enforcing preset in the GAME Code language.[All Comments] [Add Comment or Rating]
Daniel Zacharias wrote on Thu, Jan 19, 2023 07:32 PM UTC:

Is there any reason for the pawn function to include non-capturing moves since the actual movement is handled by the subroutine?


🕸📝Fergus Duniho wrote on Thu, Jan 19, 2023 04:18 PM UTC in reply to H. G. Muller from 11:50 AM:

If this is 'Post-Move' code, the Pawn has already landed on the to-square, so that it is no longer empty?

Correct.

verify == captured @;

verify not capture; should also work.

For my understanding: why is it necessary to copy the screen to a variable, before testing it. Is there a problem with writing

capture screen;

When I started what became the GAME Code language, I started with commands, which simply took arguments, and I let arguments be separated by spaces. I added expressions to the language later, and I used Polish notation, which also used spaces as separators, because it was easier to implement than infix syntax with parentheses, and its prefix syntax would be quicker to interpret too, which matters for an interpreted language written in another interpreted language. Because of these choices, it's not easy to distinguish between an expression and a list of arguments. So, instead of letting an expression be used anyplace an argument can be used, only some commands can interpret expressions. These include commands for setting variables or for controlling the flow of the program.


H. G. Muller wrote on Thu, Jan 19, 2023 11:50 AM UTC in reply to Daniel Zacharias from 05:04 AM:

If this is 'Post-Move' code, the Pawn has already landed on the to-square, so that it is no longer empty? Try

verify == captured @;

For my understanding: why is it necessary to copy the screen to a variable, before testing it. Is there a problem with writing

capture screen;

?


Daniel Zacharias wrote on Thu, Jan 19, 2023 05:04 AM UTC in reply to Fergus Duniho from 02:47 AM:

That helped a lot! Now I have this, which does capture, but the check for whether the destination is empty doesn't work, and I haven't found a way to have the post-move code check the value of the piece captured in this way.

sub P from to;
    verify > rank #to rank #from;
    verify (empty #to);
    verify or (checkaride #from #to -1 1 or checkaride #from #to 0 1) (and == distance #from #to 2 or checkahop #from #to -1 1 checkahop #from #to 0 1);
    set hopped screen;
    if (not empty #hopped):
        capture #hopped;
    endif;

🕸📝Fergus Duniho wrote on Thu, Jan 19, 2023 02:47 AM UTC in reply to Daniel Zacharias from 02:17 AM:

The line capture screen will not work, because the capture command cannot evaluate an expression. Save the value of screen to a variable, then use the variable with the capture command.

Also, the value of screen is set after calling checkahop, but you are calling screen before checkahop. Remember that expressions are evaluated from end to front, which is the reverse of reverse polish notation, or just polish notation. So, your code should look like this:

verify checkahop #from #to -1 1 or checkahop #from #to 0 1;
verify islower screen;
set scrn screen;
capture #scrn;

Daniel Zacharias wrote on Thu, Jan 19, 2023 02:17 AM UTC:

I'm trying to follow these instructions to enforce the rules for this game, but I've run into trouble with my pawn subroutine. I want the pawns to capture by jumping over one piece to an empty space, but the hopping move isn't accepted as legal.

sub P from to;
    verify > rank #to rank #from;
    if capture:
        die "A Pawn may only capture by jumping over a piece immediately in front of itself.";
    elseif == distance #from #to 2: 
        verify checkahop #from #to -1 1 or checkahop #from #to 0 1 and islower screen;
        capture screen;
    else:
         verify checkaride #from #to -1 1 or checkaride #from #to 0 1;
    endif;
    if onboard where #to 0 #pzs or onboard where #to -1 #pzs:
        if != space #to moved:
            die "You may not promote a Pawn until it reaches the promotion zone.";
        endif;
    elseif == P space #to:
        askpromote #wprom;
    elseif not match space #to var wprom:
        set np space #to;
        die "You may not promote your Pawn to a" #np;
    endif;
    set nopvc 0;
    return true;
endsub;

🕸📝Fergus Duniho wrote on Tue, Mar 22, 2022 05:01 PM UTC:

Attention Game Courier Developers

While working on a preset for Miller's Spherical Chess, I was using the problem composer to set up positions for testing whether the pieces had the correct moves. While doing this, I happened to have the white King on h1 while testing its powers of movement, and it had nine moves highlighted as legal. I eventually figured out that it was counting the castling moves as legal even though I had no Rooks on the board.

To fix this, I replaced this code:

setflag a1 a8 h1 h8 e1 e8;

with this code, which conditionally checks whether the right piece is on each space before setting the flag.

if == K space e1:
  setflag e1;
endif;
if == R space a1:
  setflag a1;
endif;
if == R space h1:
  setflag h1;
endif;
if == k space e8:
  setflag e8;
endif;
if == r space a8:
  setflag a8;
endif;
if == r space h8:
  setflag h8;
endif;

The reason the King was getting an extra legal move on h1 is because h1 was flagged for the Rook. When I tried the King on g1, it had only 8 legal moves. By setting each flag conditionally, a problem will not allow castling unless a King and Rook are in the right positions for castling. I have made this change to the Chess preset, and with appropriate modifications, it should be made for any preset that allows castling and uses flags to control when castling is allowed.


7 comments displayed

LatestLater Reverse Order Earlier

Permalink to the exact comments currently displayed.