hgm wrote: ↑Tue Aug 14, 2018 11:06 am
I don't understand your code at all, in particular how it can be that you do the same thing for squares that got occupied and that get evacuated. Also I don't know what exactly you want to store in the attack map.
This code
Code: Select all
pieceAttacksFromBB(pieces[sq], sq, occupiedBB)
returns an empty bitboard when there is no piece in the sq, so it basically updates attacksBB with 0 when the sq is evacuated. So attacksBB[from] is assigned empty bitboard, etc. Note that this is done after all the pieces are moved in the internal board structure. To save the same process in the undomove, before the update in domove, one can save the relevant sq and attack bitboard into a vector/array and just restore the attack map from there. The toUpdateSliders are the discovered sliders. As suggested here, it can be optimized by checking for preconditions (checking for sliders by rank/file/diagonal/reverse-diagonal masks or per ray direction or a kogge stone method as suggested by Gerd).
The attack map is supposed to be used as a replacement for calls to the slider attack functions e.g. move generation, eval, etc. Since I only have perft working at the moment the attack map is not that useful. Besides the fact that the slider move generators are already fast (magic bitboards).
What I did is just a quick hack to experiment with using attack maps. In the future when I'm already done with the eval, I'll try it again and we will see if there is an improvement.