Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards, pre-computing moves, and blocked squares?

Author: Dann Corbit

Date: 10:42:39 11/30/04

Go up one level in this thread


On November 30, 2004 at 13:25:08, James Swafford wrote:

>On November 30, 2004 at 12:51:38, Andrew N. Hunt wrote:
>
>>Hi!
>>
>>I've recently implemented bitboards (standard and rotated) and have a question
>>about pre-computing moves which contain blocked squares. Let's say I have the
>>occupied rank:
>>
>>bQ, wN, _, wR, _, bP, bN, _
>>
>>and I want to find the valid moves for the white Rook. How do I handle modifying
>>its bitboard rank: 11010110 to remove the blocked squares and only store the
>>available squares: 01101100? (which I can then And with the white/black pieces
>>to find valid Rook moves)
>>
>>Maybe I'm missing something obvious... :-?
>
>You need to precompute a two dimension array
>Bitboard rank_moves[64][256].  The first index is the square
>the rook is on.  The second index is the state of the rank
>(in this case 11010110 base 2).
>
>You'll need a similar array for files and diagonals
>(one for the a1->h8 direction and one more for the h1->a8
>direction).
>
>Just build these arrays in your program initialization
>by doing some looping.

You can get by with 128 entries instead of 256 in most cases, because a piece
never attacks or defends the square it is standing on.



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.