Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: a question about initializing bitboards

Author: Dieter Buerssner

Date: 08:08:43 01/08/03

Go up one level in this thread


On January 08, 2003 at 09:41:54, Uri Blass wrote:

>I want to initialize my pawn bitboards
>I started by doing for every square of a pawn
>
>pawnBB[color(square)]|=(1<<square);
>
>I changed it to
>pawnBB[color(square)]|=((Bitboard)1<<square);
>
>Do I need to do it?

Yes. In Standard C99 (which is not supported yet by MSVC) you could write:

pawnBB[color(square)]|=(1ULL<<square);

MSVC has a similar method. In this specific case, on 32 bit platforms, it might
be faster, to have some previously initialized masks (and array of 64
Bitboards), and use this instead.

pawnBB[color(square)]|=SetMask[square];

While shift is not really inefficient on x86 for 64 bit types, it most probably
needs a branch (checking if square <= 32), and the table lookup could be faster.

Regards,
Dieter



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.