Author: Klaus Friedel
Date: 22:40:41 09/22/02
Go up one level in this thread
On September 22, 2002 at 11:09:56, scott farrell wrote:
I tried using bitboards for my own Java engine, but it doesn't pay off.
A simple 0x88 representation was _much_ faster. I think using bitboards only
makes sense if your able to do some very lowlevel tricks. Using high-level
languages 0x88 will always be faster...
Regards,
Klaus Friedel
>I have a board.Count method in my Java code, and it seems excessively slow. So
>much so I had to mostly exclude it from my evaluate function.
>
>I am coding in java I know, but I dont have any idea how this code even works (I
>borrowed it from deja a few months back - it was faster than a loop of 0 to 63).
>
>I found it was slow even counting a few bits that were on, say for counting the
>number of squares a bishop could move to.
>
>Can someone give me an opinion if these is reasonable code. Or is any sort of
>counting in bitboard is fately slow.
>
>Thanx
>Scott
>
>Here is the code:
>
>static final long ONES = 0x5555555555555555L;
> static final long TWOS = 0x3333333333333333L;
> static final int FOURS = 0x0f0f0f0f;
>
>public static final int count(long set) {
> set = (set & ONES) + ((set >>> 1) & ONES);
> set = (set & TWOS) + ((set >>> 2) & TWOS);
> int result = (int) (set & 0xffffffff) + (int) (set >>> 32);
> result = (result & FOURS) + ((result >>> 4) & FOURS);
> return (result * 0x01010101) >>> 24;
> }
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.