I considered adding a function to selectively generate checks. The idea was to tabulate the squares where a piece of a certain type could deliver check, (what you call TO square), relative to King square, as a function of the current piece position (relative to King square). For sliders it would then have to be checked for each target if the rays King-TO and piece-TO were not blocked.grant wrote:I just thought of trying a quick calculation to get my TO square in my generate checks function, which also does not require magics.
I grew less enthousiastic for this idea as I realized that a Queen can have 12 possible TO squares, while in the middle-game Queens often has less than 12 moves. So for a Queen it is probably more efficient to just generate the moves, and test if they check.
Now I think it is more efficient, in the process of King-safety determination, to differentially maintain a table where checks are possible (taken the Pawn shield into account). With good King safety, as the engine would maintain in most of the tree in the middle-game, there should be no non-capture slider checks amongst this, except on the back rank. So the problem would be reduced in most cases to figure out if there are Queen or Rook moves to the back rank, which is comparatively cheap to figure out by normal move generation for forward moves of these 3 pieces only.