Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How can you get the number of a bit which is set in a bitboard ?

Author: Robert Hyatt

Date: 17:59:28 08/19/99

Go up one level in this thread


On August 19, 1999 at 18:12:35, Johannes Buchner wrote:

>Hi there !
>
>I just wanted to know if anybody out there knows a different way how to do this
>than using table-lookups like crafty. Is really no other mathematical
>possibility ? By the way, do you know any Internet resources that deal with
>problems like this (I think there is a method to do popcount without
>table-lookups, e.g.) ? In the 'Dark Thought' description they're talking about
>'Hacker's memory', a 'well-known collection of programming tricks'. Ever heard
>of it ? I haven't !
>So if you know anything intersting about that topic, please let me know (and all
>the otherz of course !)
>
>         Thanks Johannes


Crafty doesn't use a table look-up, unless it is on a non-intel machine.  On
the Intel platform, it uses BSF/BSR hardware instructions.  Other processors
have such instructions (Cray has leading-zero which is the same thing).

There's no mathematical method to compute this that anyone knows of, although
that doesn't mean no such method exists.

But there are a lot of bit-twiddling tricks... you can find many of them in
the Crafty source scattered around.



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.