Closed hwatheod closed 2 weeks ago
Very nice!
I cannot think of a simple general rule to capture this.
Any ideas?
I hard coded some illegal configurations like this one in Retractor (issues 40 through 43), but soon you discover there are endless such configurations.
I developed a more general method of cages, but it is not fully automated. It requires the user to specify the squares containing the illegal configuration of interest, and then the algorithm verifies that the configuration is illegal. Not all illegal configurations can be verified by the algorithm, but many can. Probably there are some heuristics that one could implement to find cages, but I have not worked on that.
I think we can solve all these situations with the same technique I used for https://github.com/miguel-ambrona/D3-Chess.
Namely, it is like the "steady" concept, but instead of "not steady unless proven otherwise" we go for "not mobile unless proven otherwise".
That is, for every piece on the board, we try to see if it can retract to an empty square, or to a square where there is a piece that can retract somewhere else (leaving the square empty). After saturating that logic, we'll end up with pieces that certainly cannot retract. If any of these pieces is not in their original square, the position is illegal.
Sherlock doesn't detect this position as illegal:
4k3/8/8/8/8/4P3/1K1PRP2/4b3 b - -
The bishop, pawn, rook configuration at the bottom is illegal.