Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: move ordering and bitboards

Author: Landon Rabern

Date: 12:28:56 06/23/00

Go up one level in this thread


On June 22, 2000 at 20:13:16, John Coffey wrote:

>On June 21, 2000 at 21:29:33, Robert Hyatt wrote:
>
>>On June 21, 2000 at 18:47:12, John Coffey wrote:
>>
>>>In follow up to Why Bitboards at all?
>>>
>>>If bitboards can be used to generate captures, then I assume that these
>>>are searched first to improve move ordering.  Is there any effort to
>>>determine which capture should be looked at first and do bitboards provide
>>>other ways to improve move ordering?
>>>
>>>John Coffey
>>
>>One answer is to do what I do.  Use bitboards to produce a move list with
>>nothing but captures.  Then sort the list of captures in any way you want.
>>Another answer is to use the "belle" approach and use MVV/LVA (most valuable
>>victim, least valuable attacker) as the ordering strategy and produce the
>>moves one at a time, as you search them.
>>
>>
>>
>>
>>
>>>
>>>Being a novice to bitboards I am trying to figure out how to generate a
>>>capture.  If I take a square and then I say take the mask for the moves of
>>>a bishop for that square, then I have a mask that covers 14 squares.  If I & it
>>>with a mask for my opponent's pieces I have a mask of potential captures
>>>assuming that no pieces were in the way.  So first I would have to come up
>>>with a mask for legal moves for the bishop before determining the captures?
>>>This I am not sure how to do, but I am going to try to read up on bitboards.
>>
>>
>>
>>
>>Just use the normal approach to produce the bit vector with 1's for _every_
>>square that a bishop attacks.  AND this with the occupied squares bitmap for
>>the opponent and you just eliminated all bishop moves except for the ones
>>that capture opponent pieces...
>
>
>The thing that I am missing is the "normal approach" or how to get the *legal*
>moves for a piece with bitboards.  A bishop can atack 14 squares, but some
>of those squares are blocked.  How to mask out the blocked squares?
>
>John Coffey
This is how I do it:

Say I wanted to get white horizontal rook moves, I have a precomputed 2
dimensional array of bitBoards, the first index is the square my rook is on, the
second is the state of the rank I am on(an 8 bit char showing occupied squares).
 I put these two indexes in and I get out all the places I can move to on this
rank up to and including the first 1 bit I hit.  I & this with allBlackPieces
and I have all my horizontal rook captures for this rook.

Now for vertical I just rotate the bitBoard for my rooks 90 degrees
counterclockwise(this is precomputed of course, not done on the fly). and
extract the 8 bits that show the state of the file(which in rotated form looks
like a rank).  I put this into my lookup table and and it with blackpieces and I
have all file moves.

Now just or the file and rank moves and you have all the rook moves.

For bishop moves, do the same thing, but dont rotate 90 degrees, rotate 45.

Hope this helps,

Landon W. Rabern



This page took 0 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.