Pradu wrote:Making and unmaking moves is slow for bitboard regardless. But perhaps you can optimize your kingsafety code with either flood-filling or specialized magic routines and have it be significantly faster than mailbox for this.
Flood-filling would be terribly slow on 32-bit CPUs, wouldn't it? At the moment, even though I would be happy to see a significant speedup on 64-CPUs, the performance on 32-bit hardware is still by far the most important. The majority of computer users will still run their chess programs on 32-bit CPUs for several more years, I think.
Specialized magic routines might be an option, but that would probably force me to add one or two new big tables to my program, which seems unattractive. Nevertheless, it is possible that I will eventually try something like this.
I haven't looked into Glaurung to see how you do kingsafety but I suppose it is the usual way of counting the number/type of attackers to squares around the king.
Yes and no. This is what Glaurung 1.x does. In Glaurung 2.x, I am currently using a cheap surrogate king safety. I don't consider the attackers or defenders for each square around the king separately, because I haven't found a fast way to compute it. Instead, I just find the number and types of pieces which attack
some square around the king, without bothering to find out precisely which squares each piece attacks. This is a lot faster, but of course nowhere near as good.
It is quite strange scanning for attacks in a single direction is faster for you, do you have a SEE to bench for mailbox and bitboards?
My SEE runs at similar speed with both representations, I think, but SEE is a poor benchmark for finding attacks in a single direction. SEE isn't about finding attacks in a single direction, but about finding
all pieces attacking a given square. I do this in entirely different ways with mailbox and bitboard code: With mailbox code, I loop through each piece and check whether the piece attacks the destination square. With bitboards, this approach is extremely slow, and I do almost the opposite: I begin with the destination square and compute an attackers bitboard by generating sliding attack bitboards in all directions from the square and ANDing the attack bitboards with sliding pieces.
A better example of a basic operation where I struggle to make bitboards perform well is testing whether a move gives check.
Tord