Check out Symmetric Chess, our featured variant for March, 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 EarlierEarliest
Game Courier Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
A. M. DeWitt wrote on Fri, Oct 15, 2021 07:25 PM 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 Thu, Oct 14, 2021 12:22 PM UTC in reply to A. M. DeWitt from 04:06 AM:

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.


A. M. DeWitt wrote on Thu, Oct 14, 2021 04:06 AM UTC in reply to Fergus Duniho from Sun Oct 10 11:15 PM:

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 Mon, Oct 11, 2021 06:48 PM 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 Sun, Oct 10, 2021 11:15 PM UTC in reply to A. M. DeWitt from Sat Oct 9 01:23 AM:

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.


A. M. DeWitt wrote on Sat, Oct 9, 2021 01:23 AM UTC in reply to Fergus Duniho from Wed Oct 6 04:52 PM:

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 Wed, Oct 6, 2021 04:52 PM UTC in reply to A. M. DeWitt from 02:17 PM:

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 Mon, Aug 9, 2021 04:58 PM 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 Thu, May 6, 2021 11:53 PM UTC in reply to Fergus Duniho from Tue Feb 16 10:02 PM:

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 Sun, Apr 25, 2021 06:19 AM UTC in reply to Jean-Louis Cazaux from Sat Apr 24 10:59 AM:

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


🕸📝Fergus Duniho wrote on Sun, Apr 25, 2021 02:00 AM UTC in reply to Jean-Louis Cazaux from Sat Apr 24 10:59 AM:

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 Sat, Apr 24, 2021 10:59 AM 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


🕸📝Fergus Duniho wrote on Wed, Feb 17, 2021 09:20 PM UTC:

How to replace piece labels without using aliases

The Alfaerie:Many set uses many cryptic labels that include punctuation, and it would be best to avoid using these to represent your pieces in games. In the past, you could set aliases to avoid using these labels, but you would also have to meticulously make sure you used the aliases rather than the labels. Instead of doing this, you may now completely replace the original labels with new ones. Here is how to do it. This code has all been tested and saved to an example preset.

  1. Use the labels defined in Alfaerie:Many in your FEN code while designing the board. In my example, I used {.df}n{b$}qk{b$}n{.df}pppppppp32PPPPPPPP{.DF}N{B$}QK{B$}N{.DF}.

  2. Create two arrays, one for regular pieces, and one for flipped pieces. Depending on the set file, you may not need one for flipped pieces, but Alfaerie:Many does include some flipped pieces. So, you have to include it for this set.

set mypieces ();
set myflipped ();
  1. For the pieces that will remain unchanged, simply add them to these arrays like so:
foreach label (k K q Q n N p P):
  setelem mypieces #label pieceimg #label;
  setelem myflipped #label flipimg #label;
next;
  1. For pieces that will be relabled, assign the appropriate images to your new labels. These use the pieceimg and flipimg operators to return the images for regular and flipped pieces. It then replaces the old pieces on the board with the new ones that have more appropriate labels. It uses an array of all spaces for this task.
set sp spaces;
foreach pair ((.df r) (.DF R) (b$ b) (B$ B)):
  setelem mypieces #pair.1 pieceimg #pair.0;
  setelem myflipped #pair.1 flipimg #pair.0;
  replace #pair.0 #pair.1 all #sp;
next;
  1. Reassign values to both $pieces and $flipped:
setsystem pieces #mypieces;
setsystem flipped #myflipped;
  1. Update the value of $originalpieces:
setsystem originalpieces currentpieces;

🕸📝Fergus Duniho wrote on Tue, Feb 16, 2021 10:02 PM UTC:

I have added the pieces system variable. This is the array stored in a set file. Its keys are piece labels, and its values are the filenames of image files. It basically tells which graphics to use for the pieces. I also fixed things so that you can set or get specific values of this array. This is done by following the variable name with a period and the element name. Because this will not work for labels that include periods, I have also added the pieceimg operator. This returns a specific element of the $pieces array.

The point of this is to make it even easier to support multiple sets when matching sets have not been provided. It can also be used to eliminate the need to use aliases. Here is how it may be used:

  1. Set groupsets to an array of the allowed sets. Each should be the basename of a set file:
setsystem groupsets array abstract5 alfaerie-many;
  1. Create an empty array:
set mypieces ();
  1. For any pieces whose images already have the same label in different sets, set the corresponding elements of your array to those pieces:
set mypieces.k $pieces.k;
set mypieces.K $pieces.K;
set mypieces.q $pieces.q;
set mypieces.Q $pieces.Q;
set mypieces.r $pieces.r;
set mypieces.R $pieces.R;
set mypieces.b $pieces.b;
set mypieces.B $pieces.B;
set mypieces.n $pieces.n;
set mypieces.N $pieces.N;
set mypieces.p $pieces.p;
set mypieces.P $pieces.P;

Or just:

foreach label (k K q Q r R b B n N p P):
  setelem mypieces #label pieceimg #label;
next;
  1. For each allowed set, use an if-elseif-else block or a switch-case block to set an individualized value for any pieces that are different between sets:
if == pieceset abstract5:
  set mypieces.s $pieces.s;
  set mypieces.S $pieces.S;
elseif == pieceset alfaerie-many:
  set mypieces.s pieceimg .de;
  set mypieces.S pieceimg .DE;
endif;
  1. Change the value of $pieces to that of the array you created:
setsystem pieces #mypieces;

Although you could have edited $pieces directly, this has the advantage of stripping $pieces of all the pieces you will not be using in your game.


🕸📝Fergus Duniho wrote on Tue, Feb 16, 2021 07:17 PM UTC:

I have added the system variable groupsets and the nullary operator pieceset. My intention behind adding these is to allow a developer to support multiple piece sets even when he cannot find piece sets that use the same keys for the same pieces.

Here is how to do this:

  1. Check the box for "Bypass Error Check on Piece Label".
  2. In the Pre-Game code, use setsystem to set groupsets to an array of the basenames of the sets you will allow a player to select from.
  3. Still within the Pre-Game code, use an if-elseif-else block or a switch-case block to check the value of pieceset against the basename of each allowed set, use the add command to change the pieces on the board to match the images you want to use from that set, and use the alias command to set appropriate aliases.
  4. Within your other code, consistently do operations on the piece aliases rather than the piece labels. Note that the fairychess include file is already designed to do this, and it is the recommended include file for new games.

🕸📝Fergus Duniho wrote on Tue, Jan 12, 2021 07:15 PM UTC:

I have started work on updating the documentation to include previously undocumented operators. I'll update this comment as I make more progress. So far, I have gone through the nullary operators, which do not take any arguments.

I have added documentation for the previously undocumented operators: args.

I removed the following undocumented operators: debug, dump.

I removed documentation for the following non-existent operators: player.

I modified the dump command to use var_dump() instead of print_r, and I modified it to report on a single value when it is passed as an argument. The use of var_dump() adds information on the type of each value.


🕸📝Fergus Duniho wrote on Mon, Jan 11, 2021 10:28 PM UTC:

I added documentation for the new operators int and type.


Samuel Hoskins wrote on Sun, Jan 10, 2021 08:53 AM UTC in reply to Samuel Hoskins from Wed Jan 6 04:37 AM:

Where can I find an editor so I can have a piece set uploaded?

Bump. I'm making a preset for Dai Shogi and help would be appreciated.


🕸📝Fergus Duniho wrote on Sat, Jan 9, 2021 06:52 PM UTC in reply to H. G. Muller from Thu Jan 7 10:32 AM:

I[s] there a notation for octal, hexadecimal or binary constants in GAME code?

I have just added a new int operator that recognizes whether a number is a hexadecimal, octal, decimal, or binary literal and converts it to an integer. Hexadecimal literals begin with 0x, octal with just 0, decimal with nothing special, and binary with 0b. It checks the first characters to determine the base, then uses PHP's intval() function.


🕸📝Fergus Duniho wrote on Sat, Jan 9, 2021 06:25 PM UTC in reply to H. G. Muller from Thu Jan 7 10:32 AM:

I[s] there a notation for octal, hexadecimal or binary constants in GAME code?

No. My tests show that PHP has this feature, but for some reason, it hasn't carried over to GAME Code. It looks like it has to do with handling numbers as strings. In a further test I ran, PHP would convert base 10 strings into numbers, but it would not convert other bases into numbers when they were enclosed by quotation marks. Additionally, PHP's is_numeric() function does not recognize strings in other bases as numeric.

My current automation code tabulates the capability of a move as bit flags packed into a single word. And often has to test one of these flags. Currently I use the expression & << 1 N #mode for this, where N is a constant indicating the number of the bit I want to test. This slows down the program by requiring extra shift operations at run time.

While I could build in conversion to handle this, it might be more costly than using a bit shift.

I could of course calsulate how much << 1 N is as a decimal number in every case, and write that into the code instead, but this makes the code very hard to understand, susceptible to typos (N can get quite large, like 28) and therefore hard to debug and maintain.

What I do is use constants with meaningful names. Doing this makes the code much more readable, and it reduces the chance for error by limiting the actual numeric values to some constant assignments.

An alternative would be to have a bit operator such that bit N #mode would calculate & << 1 N #mode (i.e. mask out the Nth bit).

What is #mode supposed to be?


H. G. Muller wrote on Thu, Jan 7, 2021 10:32 AM UTC:

I there a notation for octal, hexadecimal or binary constants in GAME code? My current automation code tabulates the capability of a move as bit flags packed into a single word. And often has to test one of these flags. Currently I use the expression & << 1 N #mode for this, where N is a constant indicating the number of the bit I want to test. This slows down the program by requiring extra shift operations at run time. I could of course calsulate how much << 1 N is as a decimal number in every case, and write that into the code instead, but this makes the code very hard to understand, susceptible to typos (N can get quite large, like 28) and therefore hard to debug and maintain. Written as a hexadecimal it would be much more obvious and less error prone, as even for N=28 it would just read 10000000. An alternative would be to have a bit operator such that bit N #mode would calculate & << 1 N #mode (i.e. mask out the Nth bit).


Samuel Hoskins wrote on Wed, Jan 6, 2021 04:37 AM UTC:Good ★★★★

Where can I find an editor so I can have a piece set uploaded?


Jose Carrillo wrote on Thu, Oct 15, 2020 05:24 PM UTC in reply to Fergus Duniho from 04:57 PM:

Thanks again Fergus.


🕸📝Fergus Duniho wrote on Thu, Oct 15, 2020 04:57 PM UTC in reply to Jose Carrillo from 04:06 PM:

Can you delete 18. resign move from the database?

I think this is causing a problem after a won command.

Instead of doing that, which would have fixed only one game, I did a more global fix. In the won, resign, and lost commands, I replaced $movenum, which is recorded in the log, with $mline[$mln]->movenum, which is generated by the program and indicates the number of the current move.


Jose Carrillo wrote on Thu, Oct 15, 2020 04:06 PM UTC in reply to Fergus Duniho from Mon Oct 12 06:26 PM:

Fergus,

The problems with the "won" command are back.

This game is again showing the wrong winner:

https://www.chessvariants.com/play/pbm/play.php?game=Latrunculi+XXI&log=j_carrillo_vii-cvgameroom-2020-281-060

Can you delete 18. resign move from the database?

I think this is causing a problem after a won command.

= = =

Source code:


25 comments displayed

LatestLater Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.