Check out Grant Acedrex, our featured variant for April, 2024.


[ 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 Tue, Mar 24, 2020 01:47 AM UTC:

Comparing the code for Eurasian Chess to the fairychess code, the Pawn subroutines look very different. Much of the logic may be the same, but the two are written too differently to easily compare them. One point of difference is that the Eurasian code allows promotion only to a captured piece. Another is that a Pawn may advance to the last rank only if there is something for it to promote to, though this doesn't stop it from checking the king. These two things could be built into the already existing functions and subroutines for pawns if external code was used to dynamically update the values of wprom and bprom.

After thinking of this, I thought it might be more efficient to just use different functions and subroutines, because wprom and bprom would have to be updated every time a pawn promotes, and it would be simpler to keep that code in the pawn subroutines.

But one thing that has since occurred to me is that Game Courier now keeps track of captured pieces, which it didn't do when I originally programmed Eurasian Chess. So, if I were to reprogram this game using the fairychess code, I could make use of this in external code that dynamically updates the value of wprom and bprom. I would then just have to add code for limiting movement when the appropriate variable is empty.

Here's how it could work. It would begin by adding the current pieces to the captured pieces. It would then compare it to the original pieces. If there was an extra piece on the board with a matching captured piece, it would change the captured piece to a pawn. It would then compute an appropriate value for wprom or bprom from the captured pieces. I'll work on updating Grand Chess or Eurasian Chess tomorrow to make sure I have the code working right. Also, preliminary tests suggest that it is already doing some of the needed bookkeeping of captured pieces. I will look into that more tomorrow.