Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards

Author: Russell Reagan

Date: 10:26:51 02/04/04

Go up one level in this thread


On February 04, 2004 at 10:06:11, Daniel Clausen wrote:

>I'm not quite sure what you mean with "byte square into each bitboard", but I
>try to answer anyhow. :)
>
>A move in my case contains not only information about the from-  and the
>to-square, but also about the type of piece which moves. (and other things).
>What I do is basically this:
>
>makeWhiteMove(Board* b, Move mv)
>{
>   [...]
>
>   switch(mv.pieceType)
>   {
>      case KNIGHT: update white_knights;
>                   update white_pieces;
>                   [...]
>                   break;
>
>      case ROOK:   update white_rooks;
>                   update white_pieces;
>                   [...]
>                   break;
>
>      [...]
>
>   }
>
>   [...]
>}
>
>Alternativly, if your move type doesn't contain the piecetype information, you
>have could look in the pieces[64] array of your board structure. If you also
>don't have that, then you really have a problem, because then you have to check
>all bitboards and see in which one the bit is set for your from-square.
>
>HTH
>
>Sargon

I initially tried it another way, using an array lookup. So for instance, where
you do something like this:

switch (piece_type)
{
    case white_pawn:   UpdateWhitePawnBitboard(from_square, to_square);   break;
    case white_knight: UpdateWhiteKnightBitboard(from_square, to_square); break;
    case white_bishop: UpdateWhiteBishopBitboard(from_square, to_square); break;
    // etc...
}

I would do something like this:

Bitboard pieces[12]; // a bitboard for each piece type

UpdateBitboard(pieces[piece_type], from_square, to_square);

I'm not sure which is better or faster. My hope is that when I do something like
pieces[white_pawn] that since white_pawn is a constant, it will know the address
of that bitboard at compile time, so it will be just the same as if you had a
seperate bitboard for each piece (white_pawn_bitboard, white_bishop_bitboard,
etc.).

I've even gone so far as to make the values of white and black and the piece
types such that they will allow me to do this:

pieces[white|knight];

That way I avoid a two-dimensional array lookup, and I can still write the code
to be color blind. So for instance, when I want to generate moves for the
knights, I just do:

Bitboard knights = pieces[side_to_move|knight];
// ...

Anyway, that's just another way to approach it. The program I wrote that did
this and used rotated bitboards was slightly faster than Crafty at node counting
(perft), for whatever that's worth.



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.