Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To bitboard or not to bitboard?

Author: Sune Fischer

Date: 05:22:44 08/31/03

Go up one level in this thread


On August 31, 2003 at 07:27:41, Tord Romstad wrote:

>On August 30, 2003 at 22:29:56, Sune Fischer wrote:
>
>>On August 30, 2003 at 14:37:44, Tord Romstad wrote:
>>
>>I think you have found some good arguments against bitboards,
>>but all representations have some disadvantages.
>>Ie. in other schemes you must struggle to keep order on a piecelist, getting
>>things reproducable seems pretty difficult to me with this.
>
>I haven't noticed any such problems using a Phalanx-style piece list ...

Okay, maybe there is no problem or if there is can probably be solved, I just
haven't devoted enough thinking-time to find a solution here ;)


>>A second classic example, is if you want to know if there is a pawn on the 7th
>>rank.
>>With non-bitboards you can do a loop with branches, or if you enumerate your
>>pieces in power of two's, you could do something like:
>>if (Pawn & (pc[a7]|pc[b7]|pc[c7]|pc[d7]|pc[e7]|pc[f7]|pc[g7]|pc[h7]))
>
>Neither of these examples are very important to me.  Generating classes
>of moves is not very interesting to me.  If I recall correctly, I spend
>less than 2% of the processor time generating moves.  Optimizing the
>program by generating moves in chunks would just complicate my program
>without giving a noticable speed gain.

Hmm, I think it is not so much adding the moves to a list that is interesting,
but rather the sorting process afterwards. The longer a list you have more time
it takes. When generating moves in batches I don't have to run through the list
to check what moves are captures and what aren't, and getting the best move out
of 5 is faster than finding the best move out of ~40 :)

>Concerning the second example, I can simply extract the pawns on the 7th
>rank from the pawn hash table, at hardly any cost.

Well that was just a simple example of course, but I'd wager such a check could
be faster if your "pc" array is in L1 cache and the pawn-hash entry isn't.
Doing stuff on-the-fly isn't always as slow as one would think.

>I have the impression that bitboards are mainly useful for doing rather
>simple things very quickly.  Most of the canonical examples of operations
>which are fast and simple using bitboards (like generating only captures
>or detecting passed pawns) are relatively unimportant to me, because
>such operations consume just a negligible fraction of the processor time
>in a slow program like mine.
>
>Perhaps my impression is coloured by the fact that the only bitboard
>program I have studied for more than a couple of minutes is Crafty.  Is
>there an open-source bitboard program with a more slow and complicated
>evaluation function (in particular, a more sophisticated king safety
>eval) somewhere?

Well, you would probably need to give a concrete example for me to answer that.
:)
Sure some things are not so fast with bitboards, doing things with masks just
tends to save those off-the-board checks - branches vs tables.

>>I could go on and on, but I don't really believe that bitboards are way better
>>than anything else, nor do I think that they completely suck.
>>To me they are just the easiest and most fun to work with :)
>
>I am happy to see that you do not have any religious opinions regarding
>this subject.  I was afraid this discussion would quickly degenerate
>to a pointless flamewar, but so far it doesn't seem to happen!

Hehe yes, there's no reason to be judgemental here, it is very obvious that "one
side" doesn't really understand what "the other side" is doing :)

-S.

>Tord



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.