Hello!
You guys remember SBAMG: Subtraction based Attack Mask Generation? Matthew Brades has pointed out that it invokes undefined behaviour by calling msb(0) sometimes. So here is the fix, in a more concise way than before.
This is really interesting. I guess it performs well too. Maybe it should get put into the chess wiki.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
First of all, a big thanks to Gerd Isenberg for explaining it so wonderfully!
Apparently I can't edit the wiki. Could someone please update the code? Here are the corrections you need to make:
Hi!
I'm sorry for the late reply.
An exception to this is sq = 0, in while case RankOuterSquare[0] & PrevSquares[0] can be 0, because RankOuterSquares[sq] mustn't contain the bit board of square sq.
And oh, thanks for giving SBAMG a wonderful CPW page!
Hi!
I'm sorry for the late reply.
An exception to this is sq = 0, in while case RankOuterSquare[0] & PrevSquares[0] can be 0, because RankOuterSquares[sq] mustn't contain the bit board of square sq.
And oh, thanks for giving SBAMG a wonderful CPW page!
Simply let ...OuterSquares[0] = 1 and PrevSquares[0] = 1 as well and msb is always defined and ThisAndNextSq at least 3. MaskEx ensures rook or bishop on square zero is excluded from attacks anyway.
Some rank 0 samples with rook (r) on square 0
on otherwise empty rank 0