Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about using firstone in bitboard

Author: Robert Hyatt

Date: 14:19:23 01/20/03

Go up one level in this thread


On January 20, 2003 at 15:39:05, Uri Blass wrote:

>On January 20, 2003 at 15:33:28, Robert Hyatt wrote:
>
>>On January 20, 2003 at 14:06:15, Uri Blass wrote:
>>
>>>I find in crafty 2 functions for firstone
>>>
>>>The first function is something has some function cntlzw that I am unable to
>>>understand.
>>
>>That is because that is not used on the X86 machines.  :)
>>
>>That is only useful on the macintosh or something based on the power-pc
>>chip.
>>
>>
>>>
>>>int FirstOne(register BITBOARD a) {
>>>  register unsigned long i;
>>>
>>>  if (i = a >> 32)
>>>    return(__cntlzw(i));
>>>  if (i = (unsigned int) a)
>>>    return(__cntlzw(i) + 32);
>>>  return(64);
>>>}
>>>
>>>I can understand only the second one.
>>>
>>>int FirstOne(BITBOARD arg1) {
>>>    if (arg1>>48)
>>>      return (first_ones[arg1>>48]);
>>>    if ((arg1>>32)&65535)
>>>      return (first_ones[(arg1>>32)&65535]+16);
>>>    if ((arg1>>16)&65535)
>>>      return (first_ones[(arg1>>16)&65535]+32);
>>>    return (first_ones[arg1&65535]+48);
>>>}
>>>
>>>I also want to know if there is a faster algorithm to find all 1's if I do not
>>>care about the order when in most cases there is a small number of 1's.
>>
>>find all 1's??  do you mean "count all ones?"
>
>No
>
>I want to evaluate weak pawns but I want to find their squares.
>
>I have a bitboard with the isolated pawns and I want to evaluate only the
>isolated pawns(not based on the number of ones).
>
>I can go in a loop on all the pawns but it is waste of time if I do nothing when
>the pawn is not isolated.
>
>Uri


Look at some of crafty's code:

while (FirstOne(map) < 64) {

do stuff

}

if it returns a 64 to start with, nothing happens...

That assumes "map" has a 1 for each isolated pawn...  Or you might do as I
do and have an 8 bit map for each file, saying "there is an isolated pawn on
this file".  One such map for each side.




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.