The site has moved to a new server, and there are now some issues to fix. Please report anything needing fixing with a comment to the homepage.



The Chess Variant Pages




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

Single Comment

The Fairychess Include File Tutorial. How to use the fairychess include file to program games for Game Courier.[All Comments] [Add Comment or Rating]
Fergus Duniho wrote on 2022-03-09 UTC

Based on how I decided to handle the King in Eurasian Chess, I made some changes to the Chinese_General code. Here is the original Chinese_General function:

def Chinese_General checkride #0 #1 1 0
and == Chinese_General const alias cond empty #0 capture space #1
or checkleap #0 #1 0 1 and flag #1;

And here is the new one:

def Chinese_General 
== distance #0 #1 1
or == var movetype CHECK
and checkride #0 #1 1 0
and flag #1;

Both functions begin by checking whether the destination space is flagged, since the code flags every space within a palace. This keeps the piece from moving out of the palace, though it does allow a move from one palace to the other, which is what allows one general to threaten the other with check.

The main difference is how it handles this threat. It now uses the CHECK movetype instead of checking the identity of the other piece. The checked subroutine sets a local copy of movetype to CHECK. So, when movetype is CHECK, that means the function is being called from within the checked subroutine.

Another difference is that it only uses checkride, and it does not use checkleap. Instead of using checkleap, the final thing it checks is the distance of the move, and it checks that only if it has not been called from the checked subroutine.

I also changed the Chinese_General-Range function. It used to be this:

def Chinese_General-Range merge leaps #0 1 0 (var kpos var Kpos);

And now it is this:

def Chinese_General-Range leaps #0 1 0;

The reason for this is that -Range functions are called only by the stalemated subroutine for checking possible legal moves, and they are never called by the checked subroutine. Since a General can never legally move to the space occupied by the other General, there is no need to include the space of the opponent's General in the spaces a General may legally move. Its ability to move there is of concern only when checking for checking threats on a space a General might move to.

I tested multiple games of Chinese Chess without any problem occurring, and I made moves to specifically test that Generals were not allowed to oppose each other, that they couldn't move outside the Palace, and that they couldn't move two spaces within the palace. So, the code described above appears to be working.