[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]
Check out Janggi (Korean Chess), our featured variant for December, 2024.
Check out Janggi (Korean Chess), our featured variant for December, 2024.
I wonder how I could best generalize the Metamachy prelude code. In Metamachy the various options are presented as a 4x3 matrix of clickable images, each image being a 2x2 composit of 4 icons in various relative positions. For Metamachy that makes sense, as the setups to be selected partain to an area of 2x2 squares.
In general the area could have any shape, e.g. a number of pieces on the back rank, and then another layout would be more natural. So it should be able to configure both the layout of the selection panel, and the layout of the individual clickable items in them. It could also be useful to allow accompanying texts, although the use of icons should be the principal method. (But in the Tamerid games it would be nice to have the name of the variant next to the icon-decorated buttons.)
So I am thinking in the direction of having the caller of a function that defines a prelude supply information on how the selection panel should look. A button in the selection panel could be defined by a character string as a mini-FEN. A numeric argument could indicate how many buttons should be displayed side by side.
Metamachy adapts the board-display routine to not show the configurable pieces, and then shuffles those according to the selection that was made. (Or by the AI: randomly.) This seems a round-about way of doing things; why not just leave the pieces away in the initial setup to begin with, and then just place them instead of shuffling them? That also saves you the work of taking them away! (And correcting the hash key for that...) Anyway, apart from how the icons must be painted on the buttons, it must also be specified to which square each position on the button corresponds, so that he piece can be moved there according to the selection. That can be an array of square numbers.
Because the selection might apply to both black and white, (as is the case in Metamachy) we might actually want to pass two such arrays. We should also account for the possibility that the prelude involves a number of selection events. And in whose turn these events must take place. E.g. white and black might be allowed to each chose their initial setup independently. I think Jocly enforces strict turn alteration, so it could be needed to skip some turns. (I think Metamachy already does this: black selects the setup, so the game must start with a dforced pass for white.) And it must be possible to provide a routine for the AI to make the selection, which would be run instead of showing the selection panel when the selection happens in the AI's turn.
Perhaps something like this: