Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards and evaluation?

Author: Robert Hyatt

Date: 13:42:55 10/06/98

Go up one level in this thread


On October 06, 1998 at 15:06:32, John Coffey wrote:

>It seems to me that you get limited information from  bitboards.  You
>can find out if any white pieces attack black pieces and vice-a-versa.
>
>What if you want to know who has the greatest mobility?  (i.e. the most
>number of legal moves)  You would have to count bits would you not?
>Is there a fast way to count bits by have table look ups?  (i.e.
>take 16 bits at a time and look up the bit count in a table?)
>
>If you want to know who controls the most squares around an enemy king then you
>would have to count bits again?
>
>If you wanted to know who controlled what squares, then it would seem that
>you would be out of luck with bitboards.
>
>John Coffey


such counting can be done by a "finite-state automaton"...  which means it can
be driven by a table lookup.  My solution, when there are many bits set, is to
take 16 bits at a time (4 chunks of the 64 bit word) and index into an array
pop_cnt[65536] where each entry of the pop_cnt[] array has the number of bits
in the binary representation of the subscript stored as the value.  IE
pop_cnt[9]=2 (9 = 0000 0000 0000 1001) which has 2 bits set.  If I know that
the number of bits is very small, I use a loop like this;

  int PopCnt(register BITBOARD a) {
    register int c=0;

    while(a) {
      c++;
      a &= a - 1;
    }
    return(c);
  }

which is *very* fast...  But for mobility, I do this:  instead of first loading
the attack bitmaps, then counting the 1 bits there, I pre-count the 1 bits in
yet another array, and rather than loading a 64 bit bitmap of attack squares for
a rank or file or diagonal, I load an 8 bit byte that is nothing more than the
number of 1 bits set in that bitmap, which eliminates most of the bit counting
in the evaluation, when using mobility...




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.