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

Game Courier History. History of the Chess Variants Game Courier PBM system.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Tue, Nov 17, 2015 04:40 PM UTC:
It now works for castling, and I have added support for CSS. It works by using a GAME Code subroutine to make an array of all legal moves. This subroutine is based on the stalemated subroutine and may be used in place of it. The difference is it goes through all possible moves, while the stalemated subroutine would exit as soon as it found one legal move. To use it in place of the stalemated subroutine, you need to add a not. So, "not sub legalmoves" can be used in place of "sub stalemated" when checking for checkmate or stalemate. On second thought, I could replace the stalemated subroutine with a modified version of legalmoves that reverses the return value. This would make implementation of this into multiple games quicker, because the presets themselves wouldn't have to be rewritten to use legalmoves instead of stalemated. Still, care will have to be taken to make sure the subroutine used in a particular game matches its rules exactly. Since the legalmoves subroutine goes through all possible moves, including castling, which had been skipped by stalemated, it may need more finetuning for specific games. Since it makes this array using the rules of a game programmed in GAME Code, this option will not be available for a game unless its rules have been programmed.

Each entry in the array is an array of two coordinates. The first is the origin of the move, and the second is the destination. PHP copies this array into JavaScript, which then uses it to know which spaces a piece may move to. It uses this information to display the spaces a piece may legally move to, and it uses it to catch and prevent illegal moves. This will only work for moves made with the mouse. Any move may still be entered manually, and if it is, it will be up to the GAME code program to evaluate the legality of the move. When a game's rules have not been programmed, and the legalMoves array in JavaScript is null, it will not display legal moves, and it will allow any move.