Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: questions about using popcount function to count bitboard

Author: Uri Blass

Date: 12:37:03 01/10/03

Go up one level in this thread


On January 10, 2003 at 15:31:05, Bas Hamstra wrote:

>Hi Uri,
>
>Personally I use a lookup table for 8 bits at a time (count each row). You can
>see a bitboard as an array of 8 unsigned chars.
>
>BB Test = 423434234ui64;
>int Count = PopCnt(Test);
>
>inline int PopCnt(BB BitBoard)
>
>{    unsigned char* p = (unsigned char*) BitBoard;
>     return PopCnt8[p[0]] + PopCnt8[p[1]] ... + PopCnt8[p[7]];
>}
>
>You have to create an small precalculated array PopCnt8[256] for this. It is not
>the absolute fastest, but also not much slower than that.
>
>Bas.

Thasks but I have already that array for other purpose so I do not need to
create it.

I simply thought that if there is a simple way to do things faster I can do it.
I want to use it to calculate the number of protected passed pawns because as
first step I plan to give a static bonus for passed pawn that is protected by a
pawn(I may change it later to something better but passed pawn that is protected
by a pawn is usually good not like other passed pawns that may be often bad).

I admit that in this case I can add only 5 numbers because protected passed pawn
cannot be in the first second or last rank so maybe your idea is faster.

Uri



This page took 0 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.