Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboard question

Author: Robert Hyatt

Date: 07:26:38 07/07/03

Go up one level in this thread


On July 07, 2003 at 09:21:17, Jarkko Pesonen wrote:

>In Crafty bitboard function FirstOne gives 12 and LastOne gives 53.
>Is there fast implementation for LeftOne and RightOne, which
>would give in below case 33 and 38.
>C implementation would ne appriciated.

I use this to detect outside passers, outside candidates, etc.  The idea
is to create an 8 bit mask with a 1 bit where there is a pawn in that file
and a zero elsewhere.  Now a simple "firstone" or "lastone" will find the
number of the file with the leftmost or rightmost pawn.  Once you know that,
and the pawn board with a mask of all 1's in that particular file, firstone/
lastone that and you have the square of the leftmost or rightmost pawn.

You can build the first 8 bit mask for free, simply by ORing in 1 bits as
you evaluate pawns and fine a pawn on the board.  Take it's file and OR
it in.

>---+---+---+---+---+---+---+---+
>   |   |   |   |   |   |   |   |
>---+---+---+---+---+---+---+---+
>   |   |   |   |   | *P|   |   |
>---+---+---+---+---+---+---+---+
>   |   |   |   |   |   |   |   |
>---+---+---+---+---+---+---+---+
>   | *P| *P|   |   |   | *P|   |
>---+---+---+---+---+---+---+---+   0x0080000062000400
>   |   |   |   |   |   |   |   |
>---+---+---+---+---+---+---+---+
>   |   |   |   |   |   |   |   |
>---+---+---+---+---+---+---+---+
>   |   |   |   |*P |   |   |   |
>---+---+---+---+---+---+---+---+
>   |   |   |   |   |   |   |   |
>---+---+---+---+---+---+---+---+
>
>thanks in advance
>
>Jarkko



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.