For Jazz and SjaakII that is indeed more or less what I do, but of course testing for attacks using bitboards is fast because for leapers you can test all possible locations in one test and for sliders you you don't need to scan along the entire ray (and you get at least 2 or 4 rays per check, depending on whether you do simple kinder-garten or full magic bitboards).hgm wrote:The bent sliders are indeed a pain, as well as the large number of oblique leaps. I don't think scanning away from the King could be competitive. (For Chess it surprisingly is not that bad, as the King is tucked away safely for most of the game, so that most rays away from it very quickly meet an obstruction.)
I'm not sure how to generalise the 0x88-test for 12x12 boards. Even then it's not a big help because of the oblique sliders.So yes, testing the pieces to see if they check seems the best method here. I don't know how you check that, but a 0x88-type test seems possible, where you very quickly see if a piece is on a square where it would deliver check on an extra board, and tabulate the direction you would have to scan from the King (if the piece was a slider) to scan the ray for blockers.
Well, for each square along a ray direction there are only two squares (for both Griffon and Rhino) from which is it could attack the king, so that's perhaps not too bad...Complication here is that for Griffon and Rhino checks you would not automatically bump into the checker during that ray scan. So you would have to tabulate in addition on what square a bent check would turn the corner.
True, that would be easier and I don't do that either at the moment. I'll inevitably add that at some point, but until I have a search (with check extension) or evasion generator it's not needed, I think.The above is for a 'from scratch' check test, though. If you merely want to know if the latest move delivered check, you would only have to test the moved piece in the way described above, and test for traditional alignment of the from-square and the King. If the ray scan from King then reaches the from-square, you would have to continue that scan not only testing for Rooks or Bishops on that ray, but also for Griffons or Rhinos on the squares on both sides next to it. (This could probably be done better using piece-list info, but as it is rare that the King connects with the from-square, that does not matter anymore.)
See, I know how to do all that using bitboards, but I have trouble seeing it with mailbox.If you want to test if the latest move put yourself in check you would have to do the above test on the from-square for non-King moves, but the 'from-scratch' test when you moved the King.
If you already were in check, and want to know if the move resolved it, you test King moves in the usual way, but other moves should be tested forlanding on the check ray, closer to the King as the checker. So presumably the in-check test would have given you the check ray (e.g. by step vector) and distance of the checker (or the corner where it moved on the ray), and you would test the king-toSqr distance and direction against that. Complication here is that capture of the checker could now be off-ray, so for Griffon and Rhino checks you would also have to test explicitly if the to-square coincides with the checker location, as it is no longer implied by the distance.
Perhaps the first order of business is to record the checking pieces and proceed from there (I don't currently do this: if I've found one checker I just return "in check" and don't bother looking for the others). A quick count suggested that you can have a discovered check by up to 3 checkers (or even 4 if you have two Gryphons but that will be very rare).
Ouch.As for Fairy-Max:
It turns out that about half the variables are (signed char), which is quite fatal for storing square numbers above 127. So I guess that to make progress towards support of larger boards I will need to convert all those to another data type...
I actually cheat a little: I have a 15x18 mailbox board, so square numbers go up to 270, but on-board squares only go up to 225 so I store square numbers in an (unsigned) char in the piece-list(which is marginally but measurably faster than storing them in an int).