Check out Janggi (Korean Chess), our featured variant for December, 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

Apothecary Chess Tournament[Subject Thread] [Add Response]
🕸Fergus Duniho wrote on Thu, Jan 14, 2021 06:58 PM UTC in reply to H. G. Muller from 09:22 AM:

To speed up fully-legal highlighting, I use a short-cut: Instead of trying all possible opponent moves to see if they capture the King, I only try those that might have been affected by the move of which we want to judge the legality.

My code is not that brute force. It does not try all possible opponent moves. It limits itself to checking whether each enemy piece can move to the King's position. So, it checks no more than one move per enemy piece. Second, it returns a true value as soon as the first check is found.

To that end it first marks all squares attac[k]ed by the opponent in the original position with its own King removed, and for every piece it makes a list of moves (origin and direction) that they obstruct. It also makes a list of pre-existing checking moves. After trying a move, it then only reruns the pre-existing checks in the resulting position (to see whether these are now resolved), plus the moves that were blocked by the moved piece (to check whether that piece was pinned). And for King moves it tests whether these go to a square that was marked as being under attack.

It sounds like this can handle riders, but what about hoppers or other complicated pieces? This reminds me of code I wrote just for Chess, which was optimized for Chess but couldn't handle every type of piece that might show up in a variant.