Page 1 of 1

Bitboard only - identifying captured piece?

Posted: Mon Mar 30, 2015 1:11 pm
by GrahamA
I'm planning on building a bitboard only move generator, and I'm trying to find the most efficient way to identify the captured piece (when there is one). I've read about move encoding with and without piece information; but either at move generation (and hence move encoding) or during makemove a capture piece type and location information is needed. Are there examples of engines that use this approach, or is it that many "man years" of trial and error have proved that the overhead of a mailbox for this single purpose is the way to go?

Thanks for any input on this topic,
Graham....

Re: Bitboard only - identifying captured piece?

Posted: Mon Mar 30, 2015 5:05 pm
by hyatt
GrahamA wrote:I'm planning on building a bitboard only move generator, and I'm trying to find the most efficient way to identify the captured piece (when there is one). I've read about move encoding with and without piece information; but either at move generation (and hence move encoding) or during makemove a capture piece type and location information is needed. Are there examples of engines that use this approach, or is it that many "man years" of trial and error have proved that the overhead of a mailbox for this single purpose is the way to go?

Thanks for any input on this topic,
Graham....

Two real choices.

(1) keep a 64-byte array where each byte contains the piece type for what is on the corresponding square;

(2) search through the bit boards for one having a 1 on the target square. Something like:

(a) you know to only check white bit boards if black is moving, that eliminates 1/2 leaving only 6.

(b) more pawns than anything so start with pawns, then knights, then bishops, then rooks, then queens and finally king.

I do (a), but I have seen some that do (b) and the speed difference is not that great, if anything.

Re: Bitboard only - identifying captured piece?

Posted: Mon Mar 30, 2015 5:40 pm
by GrahamA
Thanks for your reply. Interesting that they're closely matched, it does mean I could still go without the byte array.

Graham....

Re: Bitboard only - identifying captured piece?

Posted: Tue Mar 31, 2015 12:33 am
by hyatt
I started off using the byte array, and have not changed. I know others that did not use it (Dark Thought, Chess Guru, at least).

I doubt there is a significant difference since this is not all that common an operation.