Author: Tim Foden
Date: 01:53:45 05/10/02
Go up one level in this thread
On May 09, 2002 at 22:56:05, Dann Corbit wrote:
>On May 09, 2002 at 22:17:24, Vincent Diepeveen wrote:
>>On May 09, 2002 at 20:04:40, Dann Corbit wrote:
>>
>>please freshen up our mind what you can do with
>>the top_bit function?
>>
>>i completely forgot. something like finding all moves from here to
>>a certain square or so?
>>
>>that is... ...in a bitmap
>
>Nice to pick out pieces from a list of bits, if you are using it as a piece
>list. Just a handy way to get the first piece from a list. It has the same
>function as FirstOne(BITBOARD a) in Crafty's code.
I would have thought it was similar to LastOne() :)
Of course, it only returns a bitmap. To get a bit index (which is what
FirstOne() and LastOne() return) you would need something like this:
static int map[67] =
{
-1, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54,
4, 0, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55, 47,
5, 32, 0, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27, 29, 50,
43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56, 7, 48, 35,
6, 34, 33,
};
/* Returns bit index of top bit of x, or -1 if x = 0. */
static INLINE int LastOne( uint64 x )
{
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
x |= x >> 32;
x ^= x >> 1;
return map[x % 67];
}
// and of course you can do first one too...
static INLINE int FirstOne( uint64 x )
{
x &= ~(x - 1)
return map[x % 67];
}
Cheers, Tim.
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.