Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Population of disjoint Attacksets

Author: Dieter Buerssner

Date: 08:13:09 05/28/04

Go up one level in this thread


On May 28, 2004 at 10:56:59, Gerd Isenberg wrote:

>int popCount(BitBoard bb)
>{
>   unsigned int l = low(bb);
>   unsigned int h = high(bb);
>   l -= (l >> 1) & 0x55555555;	// count 2-bit groups
>   h -= (h >> 1) & 0x55555555;	// count 2-bit groups
>   l  = (l & 0x33333333) + ((l >> 2) & 0x33333333); // count 4-bit groups
>   h  = (h & 0x33333333) + ((h >> 2) & 0x33333333); // count 4-bit groups

l += h; // and do the next stage on l only

>   l  = (l + (l >> 4)) & 0x0f0f0f0f;	 // count 8-bits groups
>   h  = (h + (h >> 4)) & 0x0f0f0f0f;	 // count 8-bits groups
>   return ((h+l) * 0x01010101) >> 24;	 // sum 8-bit results
>}

Gerd, I think, you can combine the 2 halves already one stage earlier. Or did I
miscaclulate this? I thought, the individual counters cannot overflow at that
stage already. See also my post
http://chessprogramming.org/cccsearch/ccc.php?art_id=349781

For me, adding two counter combining stages was faster, than the multiplication.

Regards,
Dieter



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.