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

Later Reverse Order EarlierEarliest
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 Thu, Apr 11 01:02 AM UTC in reply to Daniel Zacharias from Wed Apr 10 11:51 PM:

I still don't get why the previous way wasn't working since I wasn't changing the pawn subroutine which seems to modify promotion options before the last rank.

The Pawn subroutines are only for actual moves, but nothing was being done to handle variable values of wprom or bprom for potential moves. The stalemated subroutine was supposed to provide a list of all legal moves, but it was omitting moves where someone declines promoting a Pawn. By having functions that dynamically calculate what a piece may promote to, it is now able to provide an accurate list of legal moves for games with variable promotion rules, such as Gross Chess has.

Anyway, this reveals another, but more minor, problem, which is that when a pawn gets to the promotion zone the text in the option selection box is large enough that the lines overlap slightly.

I increased the line-height and made some changes to the borders.


🕸📝Fergus Duniho wrote on Thu, Apr 11 12:33 AM UTC in reply to Fergus Duniho from Wed Apr 10 07:57 PM:

For Obento Chess, you might use functions like these:

def White_Pawn-Promote elem - rank #0 9 ((FP) (FP) (F));
def Black_Pawn-Promote elem rank #0 ((f) (fp) (fp));

That should be this:

def White_Pawn-Promote elem - rank #0 9 ((F P) (F P) (F));
def Black_Pawn-Promote elem rank #0 ((f) (f p) (f p));

Daniel Zacharias wrote on Wed, Apr 10 11:51 PM UTC in reply to Fergus Duniho from 07:57 PM:

Thank you, that does work better; although I still don't get why the previous way wasn't working since I wasn't changing the pawn subroutine which seems to modify promotion options before the last rank.

Anyway, this reveals another, but more minor, problem, which is that when a pawn gets to the promotion zone the text in the option selection box is large enough that the lines overlap slightly.


🕸📝Fergus Duniho wrote on Wed, Apr 10 07:57 PM UTC in reply to Daniel Zacharias from 01:28 PM:

In looking into this, I tested Gross Chess to see if it had the same problem, but before I could tell, I encountered another problem with it. I realized that for a game like Gross Chess it wouldn't do to use bprom and wprom as though they had static values. So I rewrote the fairychess include file and the Gross Chess code to support dynamic values for what a piece is allowed to promote to on a given space.

This makes use of some new functions that end with "-Promote". Here are the default functions for the Pawns:

def White_Pawn-Promote var wprom;
def Black_Pawn-Promote var bprom;

For backwards compatibility with the original way of handling promotions, these just return the value of wprom or bprom. And for additional backwards compatibility, the stalemated subroutine will use these functions only if the piece is not in the promotable array. So, to enable the use of these functions for providing dynamic values for what a piece can promote to, you should unset promotable or set it to an empty array. I added this line to Gross Chess after including the fairychess include file.

unset promotable;

Since the default functions return static values, they need to be rewritten for the particular game they are for. Here are the functions I wrote for Gross Chess:

def White_Pawn-Promote merge intersection var cap elem - rank #0 9 ((B N V W) (B N V W C R S) (B N V W C R S A M Q)) elem - rank #0 9 ((P) (P));
def Black_Pawn-Promote merge intersection var cap elem rank #0 ((b n v w c r s a m q) (b n v w c r s) (b n v w)) elem rank #0 (() (p) (p));

Since what a Pawn may promote to in Gross Chess depends upon the rank it is on, I used the rank value for black (or a value calculated from the rank value for white) as the index for a couple of arrays from which it extracted a particular value. For example, black can promote on ranks 0-2, as they are designated internally. So, this code will return the element of the array with the same index as the rank value:

elem rank #0 ((b n v w c r s a m q) (b n v w c r s) (b n v w))

Since white promotes on ranks 9-11, I subtracted 9 to get a value from 0 to 2 for any rank promotions are allowed on or a number that is out of range for any other rank. So, this works similarly:

elem - rank #0 9 ((B N V W) (B N V W C R S) (B N V W C R S A M Q))

Since the last rank for black is 0, and the last for white is 11, and 11-9 is 2, these list sets of promotion options in the reverse order from each other.

Since promotion options are limited to captured pieces, each function calculates the intersection of the value above with the captured pieces. This looks like this for black:

intersection var cap elem rank #0 ((b n v w c r s a m q) (b n v w c r s) (b n v w))

Finally, I get to the part that is relevant to Obento Chess. Whether it can promote to a Pawn as a way of declining promotion depends on the rank but not on what has been captured. So Pawns were not included in the main lists of promotion options. Instead, it merges the intersection calculated above with the value of another array element. Again, the specific array element is a function of the rank. Here is what it looks like for black:

elem rank #0 (() (p) (p))

Since declining promotion is not an option for black on rank 0, an empty array is provided for the element with an index of 0. This is not necessary for white, as the rank it cannot decline promotion on has a higher index.

elem - rank #0 9 ((P) (P))

For Obento Chess, you might use functions like these:

def White_Pawn-Promote elem - rank #0 9 ((FP) (FP) (F));
def Black_Pawn-Promote elem rank #0 ((f) (fp) (fp));

You could handle promotion for the other promotable pieces with similar functions for each specific piece.


Daniel Zacharias wrote on Wed, Apr 10 01:28 PM UTC in reply to Fergus Duniho from 12:56 PM:

I did copy from Gross chess. The descriptions should be fixed now


🕸📝Fergus Duniho wrote on Wed, Apr 10 12:56 PM UTC in reply to Daniel Zacharias from 03:56 AM:

Start by accurately writing the promotion rules in English. It looks like you copied the rules from Gross Chess even though Pawns in Obento Chess promote only to Flying Ox. I’ll check it out later when I’m on my desktop.


Daniel Zacharias wrote on Wed, Apr 10 03:56 AM UTC:

I'm having trouble with pawn promotion in this preset. I've set wprom and bprom and promotion does work, but it's not being optional like I expect. Instead it just auto promotes pawns as soon as they reach the promotion zone. As far as I can tell, there should be a promotion choice before the last rank even if there's only one item in wprom.


🕸📝Fergus Duniho wrote on Tue, Apr 9 04:41 PM UTC in reply to Daniel Zacharias from 03:16 PM:

That's now fixed. Thanks.


Daniel Zacharias wrote on Tue, Apr 9 03:16 PM UTC:

There's a small mistake in fairychess. Wizard-Desc says "The %s Wizard may move" which would result in duplicating the piece name if shown.


🕸📝Fergus Duniho wrote on Tue, Oct 17, 2023 01:44 AM UTC in reply to Daniel Zacharias from Mon Oct 16 10:52 PM:

It looks like you are misusing aliases. Aliases should not be set between names and labels. They should be set between names and codenames or between labels and notation. Look at the Piece Definitions and Piece Names sections, including the hidden details you need to click on to read.


Daniel Zacharias wrote on Mon, Oct 16, 2023 10:52 PM UTC:

I've been working on this game but something is wrong with the kings and I can't find the problem. Whenever I try to move a king I get an error like this.

There was no K on e1. The piece on e1 is a K.


🕸📝Fergus Duniho wrote on Thu, Feb 9, 2023 02:32 PM UTC in reply to Daniel Zacharias from 05:44 AM:

Does anything look amiss here?

   2 setconst T Tusker
   3 setconst t Tusker
   4 setconst J JumpingGeneral
   5 setconst j JumpingGeneral
   6 setconst M Minister
   7 setconst m Minister
   8 setconst H HighPriestess
   9 setconst h HighPriestess
  10 setconst E Elephant
  11 setconst e Elephant
  12 setconst Y WarMachine
  13 setconst y WarMachine
  14 setconst L BattleEngine
  15 setconst l BattleEngine
  16 setconst K King
  17 setconst k King
  18 setconst P White_Pawn
setconst p Black_Pawn
  19 setconst G Guard
  20 setconst g Guard
  21 setconst N Knight
  22 setconst n Knight

You're missing a semicolon after one line.


Daniel Zacharias wrote on Thu, Feb 9, 2023 05:44 AM UTC:

I'm trying to use the fairychess include file to enforce rules with this preset and it's giving an error I can't figure out.

The fn built-in function has not been given a valid function name or lambda function.

As well as I can tell, I have provided the proper functions for every piece.


13 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.