[ 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.
Since GAME Code is Turing-complete, you can try to use it in ways I never have. However, I would suggest taking smaller steps toward what you want. Before you write code to write GAME Code, it would help if you first had some experience programming in GAME Code. Try programming some games with it to get that experience. As a second step, you could try programming a limited version that doesn't work with XBetza code that would require suicides or free drops. Once that is done, you would be in a better position to start your more ambitious project.
Yes, it has to replay all past moves to calculate the current position.
Normally, the cost of checking legality is very low. Checking for stalemate and checkmate is more costly, and that is reserved for the Post-Game section. The assumption is then made that the game didn't end in checkmate or stalemate on earlier moves. Checking for legality after each move has the advantage of handling side effects of moves with the same subroutines used to check legality.
You could conceivably check legality in the Post-Game section. This would check legality only for the latest moves. But the side effects wouldn't be lasting unless you rewrote the latest move to explicitly include all the side effects, or you wrote Post-Move code that handles side effects without checking legality.
I would suggest instead that you make use of the variables starting with $prev and not try to calculate all legal moves just to check the legality of the latest move.