Has any of the subroutines you called changed the value of k or r?
Thanks for the suggestion, printing #k and #r as wel as #hit solved it. Not that these were changed, but #r was one less than I had expected, because the loop was not supposed to go over the entire slider path, but only over the 'internal' squares (which are always empty). And it left the final step to code after it (that also has to test the occupant to determine whether the move would be valid). That it continued with Qe3-i7 was thus the fault of this other code, and not of an extra loop iteration, as i7 was the last square on the ray. This code should have tested whether #hit was set in the loop as well.
The problem of the false mate claim should be solved now; instead of testing #hit in the condition for the do-while loop, I put a
verify not #hit;
at the end of this loop. This aborts the subroutine immediately when #hit gets set in the loop, thus also suppressing the code after the loop.
Thanks for the suggestion, printing #k and #r as wel as #hit solved it. Not that these were changed, but #r was one less than I had expected, because the loop was not supposed to go over the entire slider path, but only over the 'internal' squares (which are always empty). And it left the final step to code after it (that also has to test the occupant to determine whether the move would be valid). That it continued with Qe3-i7 was thus the fault of this other code, and not of an extra loop iteration, as i7 was the last square on the ray. This code should have tested whether #hit was set in the loop as well.
The problem of the false mate claim should be solved now; instead of testing #hit in the condition for the do-while loop, I put a
at the end of this loop. This aborts the subroutine immediately when #hit gets set in the loop, thus also suppressing the code after the loop.