Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To bitboard or not to bitboard?

Author: Sune Fischer

Date: 19:29:56 08/30/03

Go up one level in this thread


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.

But looking at different source codes, I think the big difference
is that bitboards use large tables and in return have relative few branches.
Processors and compilers get better in branch pridiction and they get more and
more cache.
Which factor eventually will dominate I can't say, but I believe the cache size
will only grow and it doesn't even seem to be a problem nowadays, so the table
sizes I don't personally worry about too much.

What I like about bitboards is that you can work on the entire board with just
a few masks.

As an example, say you have in your move generator a stage where you would like
to generate non-captures to squares not attacked by opponent pawns.

This would require you only to AND the attack board for the given piece with:
~(occupied | opponent->PawnAttacks())

Something which is of course a constant and can be pulled out of the piece loop.

For move generation, the advantage of bitboards lies not in the speed of which
it can add dumb pseudo legal moves to a list (who does this anyway?), but in the
way it enables you to generate classes of moves with minimal overhead.

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]))

Sure it saves branches, but using bitboards is just the ultimate evolution of
this.

Another, IMHO, really interesting aspect of bitboards is the floodfiller
techniques.
There is a whole new area yet to explore here, and as far as I know they
have no equivalent in non-bitboard environments.

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 :)

-S.



This page took 0.01 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.