Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: getting the least significant bit.. optimizing java :]

Author: Anthony Cozzie

Date: 11:10:22 08/13/03

Go up one level in this thread


On August 13, 2003 at 12:38:40, Johan Wessfeldt wrote:

>Im developing a chess engine in java and Im done with the move-generation.
>Ive run a couple of tests and so far so good. No perf-test failures yet! :]
>
>Ive discovered my Least significant Bit method is really slowing me down tho..
>
>The best Ive come up with so far goes like this:
>
>private int lsb(long a){
>for(int i=63;i>0;i--){
> if( (a & mask[i] ) == mask[i] ){
> return i;      }
>}
>return 0;
>}
>
>where mask[] is a vector of all the combinations.. like mask[0] = 0001, mask[1]
>= 00010, mask[3] = 00100 ... and so on.
>
>Ive tried some well known methods but with no results since Java's long(64 bits)
>datatype is signed. It messes up the bits..
>
>(All datatypes in Java are signed)
>
>Anyone have any suggesitons on how to optimize this method?

There have been thousands of posts to this forum about speeding up LSB/MSB, as
it is embedded all over the place in any bitboard engine.

There is the lookup-table-approach (someone already posted), Walter Faxon's
bitboard fold, Matt Taylor's De Bruijn floating point multiply, BSF/BSR X86
instructions, and a ton of others.  Just use the search engine.  I personally
use walter's code.

anthony



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.