How to implement allPieces bitboard?

You can discuss all aspects of programming and technical matters here.

Moderators: Harvey Williamson, Watchman

Post Reply
notosil
Posts: 1
Joined: Sun Dec 30, 2007 2:18 pm

How to implement allPieces bitboard?

Post by notosil »

Hi : I understand the main idea beside the bitboards, but don't know how to implement it..
I'm working in C and by example I have:

uint64_t allPieces, whitePawns,blackPawns, etc..

how to fill the bitboard allPieces with the initial position?

tks
bob
Member
Posts: 29
Joined: Sat Oct 13, 2007 1:24 am

Re: How to implement allPieces bitboard?

Post by bob »

notosil wrote:Hi : I understand the main idea beside the bitboards, but don't know how to implement it..
I'm working in C and by example I have:

uint64_t allPieces, whitePawns,blackPawns, etc..

how to fill the bitboard allPieces with the initial position?

tks
You just set the bits in white_pawns that represent the 8 squares a2, b2, c2, ..., h2 to "1", all others are set to "0"...

BTW it is probably better to have BITBOARD pawns[2], with pawns[0] being black pawns, and pawns[1] being white pawns... simplifies things later.
Gerd Isenberg
Member
Posts: 20
Joined: Mon Oct 29, 2007 10:28 pm
Location: Hattingen, Germany

Re: How to implement allPieces bitboard?

Post by Gerd Isenberg »

notosil wrote:Hi : I understand the main idea beside the bitboards, but don't know how to implement it..
I'm working in C and by example I have:

uint64_t allPieces, whitePawns,blackPawns, etc..

how to fill the bitboard allPieces with the initial position?

tks
allPieces is simple the union of all other piece bitboards. Dependent on the mapping, allPieces has likely the value of 0xffff00000000ffff for the initial position. You will also keep the union of all white and black pieces as well. While doing/undoing moves, it is faster to update those redundant union-sets incrementally rather than to "or" them all together each time the piece-bitboards change.

See the chess-programming wiki for further information:
http://chessprogramming.wikispaces.com/Bitboards
glenntamis
Member
Posts: 4
Joined: Tue Mar 09, 2010 10:39 am

Post by glenntamis »

Though, honestly, I found quite a few, but as yet, I'm trying to stay away from their source code. I would like my engine to be my own creation. I realize though that sometimes certain ideas that are implemented in an engine should have their origins mentioned.
zeeshan
Member
Posts: 4
Joined: Wed Nov 28, 2012 7:02 am

Post by zeeshan »

All Pieces is simple the union of all other piece bit boards. Dependent on the mapping,All Pieces has likely the value of 0xffff00000000ffff for the initial position. You will also keep the union of all white and black pieces as well. While doing/undoing moves, it is faster to update those redundant union-sets incrementally....
Post Reply