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

Enter Your Reply

The Comment You're Replying To
H. G. Muller wrote on Sat, Aug 8, 2020 02:26 PM UTC:


I have now implemented shuffling for the Applet-generated rule-enforcing GAME code. Because this involved some subroutines that could be of general use, I placed the code in a separate include file, which can also be included in hand-crafted presets, through:

include /membergraphics/MSply-test-applet-for-chess-variants/shuffle.txt;

To make the variant into one with a shuffled initial position, one then only has to specify (in the Pre-Game section) an array of what pieces have to be shuffled, and call the master shuffling routine. E.g.

set shuffleset (B N Q);
gosub ShuffleSetup;

would randomly shuffle all Bishops, Knights and Queens. Black would normally be shuffled the same way as white, unless you specify a shuffle for black separately:

set shuffleset (B N Q);
set blackshuffle (b n q);
gosub ShuffleSetup;

would independently shuffle the white and black pieces.

There are some ways to restrict the shuffle, for instance for the purpose of ensuring the Bishops stay on opposite shades. For that purpose there are some extra arrays you could specify. In particular, piece types mentioned in the array 'shaded' will be kept on the shade they were orignally on. In that case those pieces should not be mentioned in the shuffleset. E.g.

set shuffleset (N R Q K);
set shaded (B);
gosub ShuffleSetup;

If black is to be shuffled independently, it must have its own 'blackshaded' for this purpose.

An even more severe restriction one can impose is that certain piece types must remain positioned (left-right) symmetrically. This is useful if you don't want to shuffle the King-side and Queen-side wings independently, but preserve the overall symmetry. E.g. to optionally cause swapping of the Bishops with King and Queen you can do:

set shuffleset (K Q);
set symmetrized (B);
gosub ShuffleSetup;

In orthodox chess this would then result in one of the back ranks RNBKQBNR, RNBQKBNR, RNKBBQNR or RNQBBKNR. Currently this mode of shuffling cannot be combined with shade-preserving shuffles; you should not define 'shaded' and 'symmetrized' both. The blackshuffle would use an equivalent array 'blacksym'.

There finally is a possibility to restrict the shuffle in such a way that one piece will end up between two others. For this an array 'centralize' has to be defined, with two or three piece types, the first of which must occur only once, and there must be exactly two of the others in the setup. That first-mentioned piece will then always end up between the two others. This is useful in Chess960, where we could do

set shuffleset (N R Q K);
set shaded (B);
set centralize (K R);
gosub ShuffleSetup;

So far for the simple applications. It is also possible to specify a complex sequence of shuffles. This is mainly intended for interpreting Pre-Game code generated by the Play-Test Applet. But it is not so complex that it is impossible to specify such a shuffle by hand. The idea is to provide an array of arrays 'shufflespecs', where each shuffle is specified by three consecutive elements of the 'outermost' array. These three elements are then used as the shuffleset, symmetrized and shaded settings for that shuffle step. If some of those are not needed, they should be set to 0. E.g.

set shufflespecs
( (A C)   // shuffleset 1
  (N)     // symmetrized 1
   0      // shaded 1 (absent)
  (Q A C) // shuffleset 2
   0      // symmetrized 2 (absent)
   0      // shaded 2 (absent)
  (N)     // shuffleset 3
  (B)     // symmetrized 3
   0      // shuffleset 3 (absent)
   0      // make symmetric
);

The final 0 requests that black's position should be the mirror image of white's. If you want to shuffle black independently, you must omit that 0. But then you would have to specify all the shuffle steps in the array also with black pieces, or black would not be shuffled at all. In the example (starting from the setup of Capablanca Chess) you would force swapping of the B and N on both wings, or leave them unaffected, to decide whether super-pieces go onto the b- and i-file or the c- and h-file. The second shuffle would then permute all three super-pieces over the assigned locations. Finally, the Knight and Bishop might be swapped on both wings, or not at all.

 


Edit Form

Comment on the page Game Courier Developer's Guide

Conduct Guidelines
This is a Chess variants website, not a general forum.
Please limit your comments to Chess variants or the operation of this site.
Keep this website a safe space for Chess variant hobbyists of all stripes.
Because we want people to feel comfortable here no matter what their political or religious beliefs might be, we ask you to avoid discussing politics, religion, or other controversial subjects here. No matter how passionately you feel about any of these subjects, just take it someplace else.
Quick Markdown Guide

By default, new comments may be entered as Markdown, simple markup syntax designed to be readable and not look like markup. Comments stored as Markdown will be converted to HTML by Parsedown before displaying them. This follows the Github Flavored Markdown Spec with support for Markdown Extra. For a good overview of Markdown in general, check out the Markdown Guide. Here is a quick comparison of some commonly used Markdown with the rendered result:

Top level header: <H1>

Block quote

Second paragraph in block quote

First Paragraph of response. Italics, bold, and bold italics.

Second Paragraph after blank line. Here is some HTML code mixed in with the Markdown, and here is the same <U>HTML code</U> enclosed by backticks.

Secondary Header: <H2>

  • Unordered list item
  • Second unordered list item
  • New unordered list
    • Nested list item

Third Level header <H3>

  1. An ordered list item.
  2. A second ordered list item with the same number.
  3. A third ordered list item.
Here is some preformatted text.
  This line begins with some indentation.
    This begins with even more indentation.
And this line has no indentation.

Alt text for a graphic image

A definition list
A list of terms, each with one or more definitions following it.
An HTML construct using the tags <DL>, <DT> and <DD>.
A term
Its definition after a colon.
A second definition.
A third definition.
Another term following a blank line
The definition of that term.