Author: Frank Phillips
Date: 11:43:24 05/29/99
Go up one level in this thread
On May 29, 1999 at 11:33:56, James Swafford wrote:
>On May 29, 1999 at 07:55:46, Frank Phillips wrote:
>
>>What is the best way to extract the squares pieces are on from a piece-bitboard?
>> For example, if whiteKnights is the bitboard representing where white knights
>>are, how do you find the square the knights are on. Looping through the 64 bits
>>with a mask for each possible square on the board seems slow, even if you can
>>break out once the bitboard is empty.
>
>
>do something like this:
>
>my_board=position.whiteknights;
>while (my_board) {
> // get a square
> sq=MSB(my_board); // gets the most significant bit
> // clear that square from the board
> my_board^=mask[sq]; // XOR operation
> .
> .
> .
>
>}
>
>
>If you know the squares you are extracting tend to be on
>the low order side of the board, you may want to use
>"LSB( )" to extract least significant bits.
>
>I've got some more information on this on my site:
>
>http://home.fda.net/~wzrdking/chessprg.htm
>
>Good luck! :-)
>
>--
>James
Thanks Jmaes. But where is the MSB function?
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.