Comments/Ratings for a Single Item
I'm sure there's a reason for this, but why is it that having legality defined for move highlighting isn't enough to have legal moves enforced?
Why doesn't chess need to do that to handle promotions?
Promotions are a different type of move than regular moves. Instead of moving a piece from one location to another, a promotion changes the last piece to move to another piece. So, it does not change the values of $origin and $dest. To check whether a promotion has happened, you can compare the value of $moved, which was set when the piece moved from one location to another, with what currently occupies the space moved to (space $dest). When they are different, a promotion has happened, and you can deploy code for testing whether it was a legal promotion.
Why doesn't chess need to do that to handle promotions?
For a multi-part move, does the post-move code run just once for the whole thing or once for each part?
Once for the whole thing. To handle multi-part moves, you can rewind the move and handle one part at a time. For details, you can read How to Program Multi-Move Variants for Game Courier or review the code for either Marseillais Chess or Extra Move Chess.
For a multi-part move, does the post-move code run just once for the whole thing or once for each part?
Thanks it works!
It must be in the Pre-Game section, not the Pre-Move section. It was just that the unset should not have been within the if-clause, but done unconditionally.
Sorry, I really messed that up. This actually seems to work, if you put it in post-move 1. You don't need the flag.
if != #mover S and == movenum 1:
die "You must move the S on your first turn";
endif;
But how to set firstmove
flag only on the first move? Otherwise it doesn’t let White to move anything but S if flag is in Pre-Move section, and entirely anything if is in Pre-Game section.
if capture and match $old (bl br):
capture where $dest direction $origin $dest;
endif;
I put this in the post move, but when it runs it captures the piece at $dest rather than the specified location. It works correctly if I change it to
if capture and match $old (bl br):
set x where $dest direction $origin $dest;
capture #x;
endif;
but I don't see why it would make a difference
how to enforce that first white’s move must be by Superpiece
in the pre-game section add setflag firstmove;
and in post-move 1 add
if != #mover S and flag firstmove:
die "You must move the S on your first turn";
unsetflag firstmove;
endif;
Well, it works! but how to enforce that first white’s move must be by Superpiece?
You have to indicate that in the FEN of the preset. (I think by a dash.)
How to make other squares on 1 rank holes?
Well, that works as designed. When you move the Radioactive Queen away from d1, d1 disappears.
Basically anywhere theat is not inside the definition of another array. Just adding it as a line at the bottom should do.
If you want help in making a preset, it would be useful to post a link to it...
Where, after which constants/words it should be to work properly? Now it isn’t.
Unfortunately creating holes in the PTA does currently not work, and for a long time I could not repair it, because a wrong classification of the format destroyed the page on any edit. But now that I changed the format to 'text' I can fix things again, so I guess it is high time I do that. In the PTA you would create a brouhaha square by creating a hole and placing a piece on it.
The simplest way to do it now is add a line to the Pre-Game code by hand:
set brouhaha (...);
with ... a space-separated list of the square labels of the squares you want to be brouhaha squares.
In preset made through Play-test
Through the Play-Test Applet?
ok, now it does for me too. Thanks anyway.
I agree with you that it should produce f2, and that is what it produced when I ran it.
25 comments displayed
Permalink to the exact comments currently displayed.
Rule enforcement was a feature before showing legal moves was. Instead of replacing the standard method for rule enforcement, calculating all possible legal moves ahead of time was done as an extra step.
Additionally, moves sometimes had side effects that were not explicitly mentioned in the notation for a move, such as en passant capture in Chess or changing the side of a piece and placing it in hand for Shogi. This imposed the requirement of running code for the actual move when it was made.
Because calculating all possible legal moves is more expensive than just calculating whether one move is legal, it is done only in the Post-Game section. So, if rule enforcement depended upon the calculation of all possible moves for each turn, it would work only in on-going games made one move at a time, or it would have to be repeatedly done in the Post-Move sections, which would prolong the calculation of whether a series of moves were all legal. The way it currently works, it evaluates the legality of a series of moves much more efficiently than it would if it had to calculate all possible moves after each move. For the sake of efficiency, which kind of matters in an interpreted language written in another interpreted language, it makes sense to calculate all possible legal moves only when there is a choice of which move to make. For past moves, calculating all this is just overkill.
[Edit: combined 3 and 4]