Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: rotated bitboards obsolete?

Author: Gerd Isenberg

Date: 10:34:56 03/03/06

Go up one level in this thread


>I can confirm your findings. There are a few points however.
>
>I couldn't get your values to work, in a few cases the magic number seemed to
>map different bitboards to the same index.


Back home i double checked it and found no error so far, i also report the
number of possible states (1,2,4,8,16,32,64) - all unique indices.
Do we have the same square mapping?

>
>I then run the deBruijn generator myself, to get stuck on 40 values or so, for
>wich it couldn't get a magic number.

Ok, i told something from modified De Bruijns, but i didn't post the exact way i
modify them. You are right - the pure De Bruijns are not sufficent for all rays.

Here some more code snippets i use,
32-bit release run takes 13 minutes on my box:

void DBG::deBruijnFound(BitBoard deBruijn) const
{
  BitBoard ray;
  for (int x = 0; x < 11; x++) {
    for (int sq=0; sq < 64; sq++) {
      for (int dir=0; dir < 4; dir++) {
        if (notAllreadyFound(sq, dir) {
          int count = checkMagicNumber(deBruijn, sq, dir, ray);
          if ( count >= 0 ) {
            // store and report found magic
          }
        }
      }
    } // sq
    dB -= 0x0005012000030104; // some "random" const
  } // x
}

// return: number of found states
//         or -1 if failed
int checkMagicNumber(BitBoard deBruijn, int sq, int dir, BitBoard &d)
{
  static BitBoard notBoarder[4] = {
       0x007e7e7e7e7e7e00, // noEast-soWest
       0x007e7e7e7e7e7e00, // soEast-noWest
       0x00ffffffffffff00, // _north-_south
       0x7e7e7e7e7e7e7e7e  // _east_-_west_
  };
  static BitBoard one = 1;
  int count = 0;
  BitBoard t = 0;
  d = attackGetter[dir](one<<sq) & notBoarder[dir];
  clearLocks();
  do {
    unsigned int idx = (unsigned int)((t * dB) >> (64 - 6));
    if ( locked(idx) ) return -1;
    lock (idx);
    count++;
    t = (t-d) & d;
  } while (t);
  assert ( count == (1 << popCount(d)) );
  return count;
}




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.