BertTuyt wrote:I realized that my (implicit) movesort was still a little non-optimal, as I used 2 while loops for the 2 man directions.
So basically the movelist is devided in 2 ordered part.
I changed this, and now have a full ordening (only based upon BITSCANFORWARD and BITSCANREVERSE).
Bert
Well, I did exactly the same here, I added 3 functions for the reverse direction, note that the MSB() is actually not needed:
Code: Select all
// get most significant bit-number
inline uint MSB(bb_t bb)
{
return 63 - static_cast<uint>(_lzcnt_u64(bb));
}
// get most significant bit
inline bb_t BMSI(bb_t bb)
{
return 0x8000000000000000 >> _lzcnt_u64(bb);
}
// reset most significant bit
inline void RMSB(bb_t &bb)
{
bb ^= BMSI(bb);
}
And after that I changed the move-generator:
Code: Select all
void movegen_c::gen_man_sliders()
{
if (own == White)
{
for (bb_t from_bb = pos->men(own) & pos->empty() << 6; from_bb; RLSB(from_bb))
store(ptop, BLSI(from_bb), BLSI(from_bb) >> 6);
for (bb_t from_bb = pos->men(own) & pos->empty() << 5; from_bb; RLSB(from_bb))
store(ptop, BLSI(from_bb), BLSI(from_bb) >> 5);
}
else
{
//for (bb_t from_bb = pos->men(own) & pos->empty() >> 5; from_bb; RLSB(from_bb))
//store(ptop, BLSI(from_bb), BLSI(from_bb) << 5);
//for (bb_t from_bb = pos->men(own) & pos->empty() >> 6; from_bb; RLSB(from_bb))
//store(ptop, BLSI(from_bb), BLSI(from_bb) << 6);
for (bb_t from_bb = pos->men(own) & pos->empty() >> 5; from_bb; RMSB(from_bb))
store(ptop, BMSI(from_bb), BMSI(from_bb) << 5);
for (bb_t from_bb = pos->men(own) & pos->empty() >> 6; from_bb; RMSB(from_bb))
store(ptop, BMSI(from_bb), BMSI(from_bb) << 6);
}
}
It decreases the number of nodes by ~20% and it has very little impact on speed so I will leave it in.
As you will probably notice I use separate loops for each direction and I do some redundant shifts, but for clarity of the code I will leave it like it is. Nowadays the optimizers are so smart that there is a big change the redundancy is removed anyway.
Joost