You are on the backup site for Chessvariants.com. Any posts, moves, or other changes you make here will not be permanent, because the pages and database from the main site will be backed up here every midnight EST. Additionally, things may not be working right, because this site is also a testbed for newer system software. So, if you are not here to test, develop, or merely read this site, you may want to change .org to .com in the navigation bar and go to the main site.



The Chess Variant Pages




[ 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
Game Courier Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
Fergus Duniho wrote on 2022-04-10 UTC

This morning I was getting confused about what filename and rankname returned. I wanted to get the nth file or the nth rank from passing them numbers, but they only parsed coordinates and returned the file or rank name of that coordinate. So, I added the extra ability I needed to each function. If filename or rankname is passed an integer, and that integer is an array index for $file or $rank, it will now return the array value with that index. It will otherwise return an empty string. So, filename 0 will return a in Chess, and rankname 0 will return 1 in Chess.


Fergus Duniho wrote on 2022-03-12 UTC

I have added the following built-in functions: chars, string, hasalnum, hasalpha, hasdigit, haslower, and hasupper. The chars and string functions can be used together to process a string with a lambda function filter, using chars to turn a string into an array of characters, and using string to converted the processed array back into a string. For example, promoted pieces in Shogi put a plus sign before the usual piece label, and the boldfaced part of this line demotes a piece in Shogi by removing any non-alphabetic characters:

set demoted flipcase realname string filter lambda (isalpha #1) chars alias space $dest;

The has functions are similar to isalnum, isalpha, isdigit, islower, and isupper, but instead of checking whether every character in a string is of a particular type, these check whether any character, even just one, is of a particular type. These come in handy when piece labels include non-alphabetic characters, as promoted pieces do in Shogi.


Jean-Louis Cazaux wrote on 2022-01-13 UTC

Hello Aurelian. I have no plan to use them. There are probably very special to put in a CV, but not without interest.


Aurelian Florea wrote on 2022-01-13 UTC

Hello Jean-Louis, I am curious if you are interested by the horizontal counterparts of the two pieces for use in your variants.


Jean-Louis Cazaux wrote on 2022-01-13 UTC

Warm thanks to both of you. It seems to work fine for both pieces. That's great.


Daniel Zacharias wrote on 2022-01-13 UTC

That doesn't quite work, because leaps checks all four directions instead of just forwards and backwards. Maybe checkride shouldn't work either, but I tried it and it seems to.

This works for the Snake

def U fn (checkaride #0 #1 1 1 and empty #0)
    where #0 0 1
    #1
    or fn (checkaride #0 #1 -1 1 and empty #0)
    where #0 0 1
    #1
    or fn (checkaride #0 #1 1 1 and empty #0)
    where #0 0 1
    #1
    or fn (checkaride #0 #1 -1 -1 and empty #0)
    where #0 0 -1
    #1
    or fn (checkaride #0 #1 1 -1 and empty #0)
    where #0 0 -1
    #1
    or checkaleap #0 #1 0 1
    or checkaleap #0 #1 0 -1;

def UL mergeall
    ray where #0 0 1 1 1
    ray where #0 0 1 -1 1
    ray where #0 0 -1 -1 -1
    ray where #0 0 -1 1 -1
    where #0 0 1
    where #0 0 -1;

Bn Em wrote on 2022-01-13 UTC

I believe you want checkaride instead of checkride — the latter checks all directions symmetrically (making a full gryphon plus conditional wazir moves), while the former is asymmetric.

Presumably if your suggestion for the Ship is otherwise correct, the snaketongue would similarly be:

def G fn (checkaride #0 #1 1 1 and empty #0)
    where #0 0 1
    #1
    or fn (checkaride #0 #1 -1 1 and empty #0)
    where #0 0 1
    #1
    or fn (checkaride #0 #1 1 -1 and empty #0)
    where #0 0 -1
    #1
    or fn (checkaride #0 #1 -1 -1 and empty #0)
    where #0 0 -1
    #1
    or checkleap #0 #1 1 0;

def GL mergeall
    leaps #0 1 0
    ray where #0 0 1 1 1
    ray where #0 0 -1 1 -1
    ray where #0 0 1 -1 1
    ray where #0 0 -1 -1 -1;

Daniel Zacharias wrote on 2022-01-12 UTC

I think this works for the ship, but I'm not quite sure how to do the Snake

def G fn (checkride #0 #1 0 1 and empty #0)
    where #0 1 1
    #1
    or fn (checkride #0 #1 0 1 and empty #0)
    where #0 -1 1
    #1
    or fn (checkride #0 #1 0 -1 and empty #0)
    where #0 1 -1
    #1
    or fn (checkride #0 #1 0 -1 and empty #0)
    where #0 -1 -1
    #1
    or checkleap #0 #1 1 1;

def GL mergeall
    leaps #0 1 1
    ray where #0 1 1 0 1
    ray where #0 1 -1 0 -1
    ray where #0 -1 1 0 1
    ray where #0 -1 -1 0 -1;

Jean-Louis Cazaux wrote on 2022-01-12 UTC

I beg some help, this is above my skills. I do cut and try, but I'm unable to get it. I want to code a Ship (t(FvR), vertical Gryphon) and a Snake (t(vWB), vertical Manticore). I was thinking to go from Gryphon and Manticore. How should I modify those:

def G fn (checkride #0 #1 1 0 and empty #0) where #0 sign - file #1 file #0 sign - rank #1 rank #0 #1

and != file #1 file #0 and != rank #1 rank #0 or checkleap #0 #1 1 1;

def GL mergeall leaps #0 1 1 rays where #0 1 1 1 0 rays where #0 1 -1 1 0 rays where #0 -1 -1 1 0 rays where #0 -1 1 1 0;

and :

def U fn (checkride #0 #1 1 1 and empty #0) where #0 0 sign - rank #1 rank #0 #1

or fn (checkride #0 #1 1 1 and empty #0) where #0 sign - file #1 file #0 0 #1

or checkleap #0 #1 1 0;

def UL mergeall leaps #0 1 0 rays where #0 0 1 1 1 rays where #0 0 -1 1 1 rays where #0 1 0 1 1 rays where #0 -1 0 1 1;

Thanks!!!


Jean-Louis Cazaux wrote on 2021-12-20 UTC

It is me who says you many thanks!


Greg Strong wrote on 2021-12-20 UTC

These pieces have been added. Please let me know if you would like any adjustments.

Thanks, Greg


Greg Strong wrote on 2021-12-17 UTC

Hi Jean-Louis,

I will take care of this this weekend.


Jean-Louis Cazaux wrote on 2021-12-16 UTC

I use "Alfaerie for Metamachy" as a set for the GC presets of my CVs. Who could add 6 new pieces from Alfaerie , coded with 2 letters, to this set?

I would like to have added: the Snake (SN), the Ship (SH), the Bird (BI), the Tiger (TI), the Ram (RA), the Dragon (DR).

Thanks for the help.


Adam DeWitt wrote on 2021-10-15 UTC

As it turned out, I didn't need the suicides to perform the burns in Suzumu Shogi. I just needed to tweak the isdoublemove subroutine a little bit, add a FD subroutine for the Fire Demon, tweak the Fire Demon functions to include the new subroutine, and return the Fire Demon to its destination square with empty and add after it made a burning move. I love GAME code... :)


Fergus Duniho wrote on 2021-10-14 UTC

If something similar could be used to detect the type of piece affected by the suicide, that should be everything I need to enforce the burning rules using suicides, at least in theory.

That information is in #pfore. Just use the coordinates of the spaces with missing pieces as keys to this array.


Adam DeWitt wrote on 2021-10-14 UTC

This preset of yours for detecting captures is huge. The fact that it reliably detects where the suicide occured means that I can use it to test whether the suicide is a King's move away from the moving Fire Demon and ensure that no suicides are done when a non-Fire Demon moves, which should solve the majority of problems with coding the burning move. If something similar could be used to detect the type of piece affected by the suicide, that should be everything I need to enforce the burning rules using suicides, at least in theory. Best of all, I can just ask players that haven't made a burn after moving a Fire Demon rather than worry about displaying legal moves on the board.

You could adapt it. For the multi-move variants, there are usually the same number of move parts each turn. So, it makes sense for these games to do the multi-part analysis globally for all pieces. But for games that include pieces with multi-part moves, you may want to reserve the multi-part analysis for specific pieces and tailor it to each piece that needs it.

This is what the original Suzumu Shogi preset (and all presets using the same general codebase) does, which is largely thanks to its isdoublemove subroutine. So, I guess I could use integers instead of booleans and sub ismultimove instead of sub isdoublemove to keep track of which part of the move suffices. The only major problem is that I'm not exactly sure how to enforce rules for the third part of a three-part move. Perhaps I am overthinking it though. Perhaps just copy-pasting and tweaking the code for the second part of multi-moves will be enough. This requires testing, but thankfully, the Taishin Shogi preset (which is fully coded, at least for enforcing the old rules) affords just such an opportunity.

Edit: I figured out how to detect the type of piece that committed the suicide. Now we should be all good.


Fergus Duniho wrote on 2021-10-11 UTC

I realized the role that $width and $height play in centering the borders for highlighting spaces, and with that in mind, I simplified the code in draw_grid_png.php and made adjustments to the $width and $height of Shogi pieces and to the values of $offx and $offy in image_dimensions.php. By using proper values for $width and $height, the code will always apply CSS for margins and padding to the space class rather than to each element of the space class.

I didn't immediately recognize the importance of $width and $height, because I created these variables years before I ever added the ability to display legal moves by highlighting spaces. These variables describe the width and height of spaces, and they are used when automatically generating a board to know what dimensions to give to spaces. But sometimes an image of a board is used instead, and when it is used, $width and $height should match the size of the spaces on the image.

This is what I was neglecting to do. The highlighting in Shogi was a bit off, because the value of $height did not match the height of the spaces on the images of Shogi boards.

Since Shogi divides each space by lines, there are two choices on how to specify the dimensions of a space. One is to use the inner space between the lines, and the other is to extend the size to include the lines. I tried both and chose the latter for Shogi.

For automatically-generated boards, the centering of borders for highlighting should now be done automatically. But for boards provided as pre-drawn images, it's important to match them up with the correct values for $width and $height. One way would be to size the board with spaces the same size as the dimensions given for the piece sets to be used with it. Abstract and Alfaerie sets both normally use 50x50 spaces. Another way would be to provide correct values for your board. I could add these to the image_dimensions.php script for specific boards.


Fergus Duniho wrote on 2021-10-10 UTC

Another possibility for detecting a suicide move is to store the board position before the move into a variable, then compare the new position after the move to the stored position and see what differences there are.

This could potentially solve the problems of detecting a suicide move if I knew how to do it.

Here's a preset I made to demonstrate how to do this:

https://www.chessvariants.com/play/pbm/play.php?game%3DChess%26settings%3Dspotcaptures

This records the position of every piece on the board in an array whose keys are coordinates and whose values are piece labels. It does this both before and after a move. It then goes through the current positions of pieces. For each empty space, represented with the @ piece, it compares it with the previous value to see if it was empty before. If it wasn't empty before, it records it as a capture.

Since I am already writing this, would the system used for the multi-move variants be able to handle moves with three or more parts (i.e. that of the Lion Dog in Maka Dai Dai Shogi)?

You could adapt it. For the multi-move variants, there are usually the same number of move parts each turn. So, it makes sense for these games to do the multi-part analysis globally for all pieces. But for games that include pieces with multi-part moves, you may want to reserve the multi-part analysis for specific pieces and tailor it to each piece that needs it.


Adam DeWitt wrote on 2021-10-09 UTC

Since it sounds like your Fire Demon piece is making a multi-part move, you may want to break down the whole move and analyze it step-by-step. You will find examples of this in multi-move variants like Marseillais Chess and Extra Move Chess.

Hmm. Perhaps the step-by-step approach would be better. After all, the Suzumu Shogi preset is essentially on a more restrictive form of the other multi-move presets with more pieces.

So the tentative process would then be the folowing

Do a regular move

  • Normal move
  • Normal capture
  • King step (capture)
  • King step (non-capture), pass (double move)
  • Single King step (non-capture), return to origin square (double move)

Then I would need to assess whether or not there are pieces available to burn (which should be easy thanks to the burn subroutine in my Tenjiku Shogi preset). If so, after the move, do an igui capture or pass.

Or it may be simpler to simply always give the player to optionally shoot any enemy piece a King step away after moving.

Another possibility for detecting a suicide move is to store the board position before the move into a variable, then compare the new position after the move to the stored position and see what differences there are.

This could potentially solve the problems of detecting a suicide move if I knew how to do it.

Since I am already writing this, would the system used for the multi-move variants be able to handle moves with three or more parts (i.e. that of the Lion Dog in Maka Dai Dai Shogi)? This will be important for my larger games with Lion Dogs, Furious Fiends, Kirin Masters, and Phoenix Masters, as well as if I use the move breakdown method for the Fire Demon's burns.


Fergus Duniho wrote on 2021-10-06 UTC

Is there a way to detect suicide moves in GAME code?

There are two ways of doing a suicide, and these have different effects on the $old variable. Adding an @ to a space works like a promotion, which leaves the value of $old unaffected. Moving a piece nowhere gives $old an empty value. This may give a better indication that the move included a suicide, but it would come at the expense of the information about where the piece moved to.

Since it sounds like your Fire Demon piece is making a multi-part move, you may want to break down the whole move and analyze it step-by-step. You will find examples of this in multi-move variants like Marseillais Chess and Extra Move Chess.

With that in mind, another option would be to move the Fire Demon to the piece's space, then immediately move it back.

Another possibility for detecting a suicide move is to store the board position before the move into a variable, then compare the new position after the move to the stored position and see what differences there are.


Fergus Duniho wrote on 2021-08-09 UTC

Contrary to what was documented, the rlink command was not available. Maybe I accidentally used Ctrl-z too many times. So, I added it back in. I also fixed a bug in link that stopped it from working after the first pair.

I expanded the power of the map command. It was previously useful only for creating logical directions from leaps defined in terms of ranks and files. This limited it to the directions available on a simple grid. To make it easier to create directions for boards with unusual geometries, it can now be used with previously created logical directions. In the Cylindrical Chess preset I'm working on, I used link and rlink to add connections between the a and h files for east and west, and then I used map to define the diagonal and hippogonal directions without handwriting them link by link. The code looks like this:

map n 0 1 s 0 -1 w -1 0 e 1 0; // Orthogonal directions
link w (a1 h1) (a2 h2) (a3 h3) (a4 h4) (a5 h5) (a6 h6) (a7 h7) (a8 h8);
rlink e (a1 h1) (a2 h2) (a3 h3) (a4 h4) (a5 h5) (a6 h6) (a7 h7) (a8 h8);
map nw (n w) ne (n e) sw (s w) se (s e);
map nne (n ne) nnw (n nw) sse (s se) ssw (s sw);
map nee (ne e) nww (nw w) sww (sw w) see (se e);

Fergus Duniho wrote on 2021-05-06 UTC

I have added the ability to use entirely custom piece sets in a game. These are defined in GAME Code and do not use an external PHP file. Here is some sample code I wrote:

// A demo of using multiple internal sets that do not match any set file.

// Name the sets you will use by assigning them to the $groupsets array.
// Use capitalized names for the sets. These do not match any file names.
setsystem groupsets array Abstract Alfaerie AlfaeriePNG Magnetic Motif;

// Define pieces in an array variable called mypieces.
// Start by creating an associative array of all pieces shared in common.
// The key should be a label, and the value should be a filename.
// A single line of code is broken into multiple lines of text for legibility.
set mypieces assoc 
  K "WKing.gif"   k "BKing.gif" 
  Q "WQueen.gif"  q "BQueen.gif" 
  R "WRook.gif"   r "BRook.gif" 
  B "WBishop.gif" b "BBishop.gif" 
  N "WKnight.gif" n "BKnight.gif" 
  P "WPawn.gif"   p "BPawn.gif";

// Set the $dir system variable to match the set, and modify filenames as needed.
if == pieceset Alfaerie:
  setsystem dir "/graphics.dir/alfaerie/";
  foreach (k v) #mypieces:
    setelem mypieces #k tolower #v;
  next;
elseif == pieceset AlfaeriePNG:
  setsystem dir "/graphics.dir/alfaeriePNG/";
  foreach (k v) #mypieces:
    setelem mypieces #k tolower str_replace .gif .png #v;
  next;
elseif == pieceset Magnetic:
  setsystem dir "/graphics.dir/magnetic/";
elseif == pieceset Motif:
  setsystem dir "/graphics.dir/motif/";
else:
  // Have a default set for when the set does not match any allowed set.
  // The default is Abstract.
  setsystem dir "/graphics.dir/abstract/";
endif;

// Now that the pieces are defined, copy the #mypieces array to $pieces
setsystem pieces #mypieces;

Aurelian Florea wrote on 2021-04-25 UTC

Jean-Louis, You can use any string enclosed in brackets. Hopefully this will help you.


Fergus Duniho wrote on 2021-04-25 UTC

You can use any string, not just individual letters. I recommend sticking to short strings of the 26 letters identified in ASCII, so that players have an easier time typing notation.


Jean-Louis Cazaux wrote on 2021-04-24 UTC

I apologise if my question is trivial, all this looks very complex for me. I want to use a set "Alfaerie for Metamachy" but for the moment it is limited to 26 pieces, using the 26 letters of the alphabet. Would it be possible to add few more using other letters such as the diacritic letters may be like é/É? Thanks


25 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.