Author: Uri Blass
Date: 10:57:59 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.
Doing it faster is simple
I know nothing about javva I use a>>16 for dividing by 2^16 but I assume nothing
about javva so I will simply say divide by 65536.
You need first to have an array
firstonearray[65536] and calculate firstone for a<65536 to fill this array.
It is done only once so speed is not important and you can use the function that
you have to calculate the array.
After that you have.
private int lsb(long a){
if (a&65535>0)
return firstonearray[a&65535];
divide a by 65536(do not know how to do it in javva)
if (a&65535>0)
return firstonearray[a&65535];
divide a by 65536(do not know how to do it in javva)
if (a&65535>0)
return firstonearray[a&65535];
divide a by 65536(do not know how to do it in javva)
if (a&65535>0)
return firstonearray[a&65535];
}
I assume that a is not changed when you get out of the function like C but I
know nothing about java.
Uri
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.