Bitboard only - identifying captured piece?

Code, algorithms, languages, construction...
Post Reply
GrahamA
Posts: 10
Joined: Tue Mar 17, 2015 12:41 am

Bitboard only - identifying captured piece?

Post by GrahamA » Mon Mar 30, 2015 1:11 pm

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....

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Bitboard only - identifying captured piece?

Post by hyatt » Mon Mar 30, 2015 5:05 pm

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.

GrahamA
Posts: 10
Joined: Tue Mar 17, 2015 12:41 am

Re: Bitboard only - identifying captured piece?

Post by GrahamA » Mon Mar 30, 2015 5:40 pm

Thanks for your reply. Interesting that they're closely matched, it does mean I could still go without the byte array.

Graham....

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Bitboard only - identifying captured piece?

Post by hyatt » Tue Mar 31, 2015 12:33 am

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.

Post Reply