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


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Interactive diagrams. Diagrams that interactively show piece moves.[All Comments] [Add Comment or Rating]
💡📝H. G. Muller wrote on Mon, Aug 3, 2020 08:02 AM UTC in reply to Greg Strong from Sun Aug 2 11:55 PM:

Without table it will in general be difficult to make a sensible promotion choice automatically. Not every variant has such an obvious default choice as orthoChess. So the idea was that people who want to seriously play would always open the table. But the diagram serves more purposes than playing (which is only a recently added capability), and for showing move diagrams or an initial position the promotion function is totally unimportant. So there is no reason to show the piece table by default.

What it now does when the table is closed is indeed a bit primitive: if promoChoice starts with a letter it takes the piece with that ID; if not it takes the forelast piece in the table (assuming the user will have specified the pieces in order of increasing value, King last, an assumption that fails for the diagrams generated by the Play-Test Applet).

I was too lazy to add a lot of code here (e.g. to check which pieces are in stock) only for the purpose of ensuring that the choice was legal (but likely still unsatisfactory) with a closed table. It is not really a disaster if the user gets a wrong piece because he forgets to open the table before promoting; he can just take back the move (and the reply) with the < button, and try again. The diagram accepts illegal moves in general, so why should illegal promotion choice be an exception? And if the table is open, but no choices are available, the user can simply click another piece on the board to abort the attempted promotion.

That being said, there are prospects for improvement here. For the purpose of the AI I wrote a completely new move generator, which creates a list of pseudo-legal moves. (And that includes all pseuo-legal promotion choices.) One of the items on my to-do list is to abandon the old move generator used for highlighting, and rewrite the mouse-click handler to interpret board clicks in terms of this list, narrowing the sub-set of possible moves as more squares get clicked, until only a single one is left. That would also cure the current limitation of only a single locust victim. And promotions for which no valid choice is available would not have occurred in the list, and not have been highlighted. I don't really feel like putting much effort in a temporary solution. (This reminds me that the AI probably does not recognize such impossible promotions as delivering check, now. But that again seems a rule that would never have to be invoked in practice.)

What should be rather easy, though, is completely remove the code that handles the case of a closed table, and open the table instead when the user promotes.

[Edit] I now uploaded a new script, which does the latter. It now also recognizes the case where nothing in the table gets highlighted, and aborts the move immediately rather than inviting the player to pick a piece.