Check out Makruk (Thai Chess), our featured variant for March, 2025.


[ 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

Play-test applet for chess variants. Applet you can play your own variant against.[All Comments] [Add Comment or Rating]
🕸Fergus Duniho wrote on Sat, Jan 9, 2021 03:33 PM EST in reply to H. G. Muller from 01:47 PM:

I call this code from the Post-Game section, though. Could that make the difference? The same code does work without problems in the Mighty-Lion preset. And I recall having tested it too for cases that allow deferral.

If you were checking the move line number with mln, it wouldn't work in the Post-Game code. The value of $mln is regularly updated by the moveindex command, which executes between moves. In the Post-Game code, mln should be equal to $maxmln. So, you would need another method for checking whether it is on the last move.

Note that the problem does NOT occur when you decline. It occurs when you choose to promote. (But only in games where there also is the option to decline.) When, in Daniel's link, I choose a white Pawn, it does play P g7-g8. But when I choose a white Zebra it dies, showing a game record that ends in:

The source code for the page shows me that the original move has not been included in the move. It just includes a blank space before the semi-colon. The value there should have been supplied by the variable $moves, and this value is entered into the Moves field when you submit a form to move. The problem may be that askpromote is being called a second time, since it should be used only when someone has submitted a move. Since this link has a query string, that cannot be the case here, for a move is always entered via POST, not GET.

Before calling askpromote, you have to check for two different things. Check that this is the very latest move, and make sure askpromote has not already been called for this move. I do not see anything in your code that is checking whether it is the very latest move. Since you are running all the moves in the Post-Game section, you will have to come up with a different method than I use. Perhaps you can count how many moves there are and allow it only on the move whose index matches the last move.