Check out Janggi (Korean Chess), our featured variant for December, 2024.

Enter Your Reply

The Comment You're Replying To
H. G. Muller wrote on Sat, Dec 30, 2023 03:09 PM UTC:

I now pushed a fully debugged version of fairy-move-model.js, and in particular the new cbPiecesFromFEN facilities, to my 'trial' branch. I also made a description of what it can do:

Facilitate definition of 'run-of-the-mill' chess variants

A routine this.cbPiecesFromFEN(geometry, fen, pawnRank, maxPush) is
provided, which will return an object that contains both the
pieceTypes object and promote function that you would have to return
in a game definition. The pieceTypes object is derived from the
provided FEN, which can contain many commonly used fairy pieces.
Such as Archbishop (A), marshall (M), (xiangqi) cannon (X), camel (C),
zebra (Z), elephant (E), champion (H), wizard (W), griffon (G),
rhino (U), vao (V), Shogi Pawn (S, for soldierw/soldierb), Lion (L)
and amazon (T).

The last two arguments are optional, and would limit the board area
where a Pawn can be pushed forward by more than 1 step, and by how
many steps, respectively. The default is that Pawns can be pushed
up to any square on their own board half only when still on the
starting rank (derived from the last white Pawn encountered in the
FEN). For variants with 8 board ranks and orthodox Pawns this default
suffices.

When no other unorthodox pieces are participating than those mentioned
above (all orthodox pieces are of course supported too!), and the
promotion rules are orthodox, defining the game can become extremely
simple. One can just feed the FEN of the initial setup to
cbPiecesFromFEN, and get the pieceTypes and promote values that
the cbDefine function has to return from there.

For example, if we use the function inside cbDefine() as

var p = this.cbPiecesFromFEN(geometry, fen);

the object with piece definitions will be p.pieceTypes. All pieces
occurring in the FEN string will be included in this. The FEN can
represent a board with more ranks than the actually defined board;
in that case only the pieces on the actually existing ranks will
be placed in the initial position as described. Other pieces will
not appear, but their type will be available for promotion.

All mentioned pieces other than King (K) and Pawn (P or S) will be
included in an array p.promoChoice, and a standard promotion function
that allows Pawns to promote on last rank to any of those will be
available as p.promote. If the default choice is not suitable,
one can assign another array to p.promoChoice, and still use p.promote.
Likewise, if the promotion zone contains N ranks rather than one,
this can be achieved by assigning p.promoZone=N.

The piece types defined with the aid of this function will all be
defined with a move graph for their usual move, and a piece value
suitable for an 8x8 board. If this is not desired, one can still
use the function to define them, but alter their graph (or any
other property) afterwards by calling

p.setProperty(name, property, newValue);

(Note that the name used for pawns is diversified by color: 'pawnw' or
'pawnb'.) This can also be used to add entirely new properties.
For adding moves to those the piece got by default we can use

p.addMoves(name, graph);

with 'graph' the graph of the moves to be merged in.

We can also define additional pieces from scratch, by writing

p.addPiece({...});

with the old-style piece definition on the dots. This function returns
the type number of the thus-added piece. If we want to know how many
types we have defined so far, we can find this in p.nr.

Note that the Lion and Amazon are now supported through L and T in the FEN. For the remaining letters I still have not decided. It only makes sense to add pieces that are frequently used, with a commonly accepted move. This sort of excludes quirks like Snaketongue and Ship. I am in doubt about Nightrider; it is well known, but not used very frequently. Grasshopper is well known, but virtually never used. (And Jocly currently does not support grasshopping anyway.) Perhaps the Crowned pieces after all (D and Y?). Or a non-royal King? The Steward (omnidirectional Pawn) also seems a reasonably popular piece.


Edit Form

Comment on the page Jocly

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.
Avoid Inflammatory Comments
If you are feeling anger, keep it to yourself until you calm down. Avoid insulting, blaming, or attacking someone you are angry with. Focus criticisms on ideas rather than people, and understand that criticisms of your ideas are not personal attacks and do not justify an inflammatory response.
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.