Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Some explanation about crbmg.cpp

Author: Sune Fischer

Date: 07:40:41 01/10/04

Go up one level in this thread


On January 10, 2004 at 08:33:35, Maurizio Di Vitto wrote:

"You" I take it that would be me, a.k.a. Sune? :)

>I am writing a chess engine with bitboard system, but I want to ask you just a
>few things about the crbmg.cpp file that I am reading. The first is why you use
>two FOR structure of 64, I mean:
>for (int s=0; s<64; ++s) //I know that's about the number of squares.
>   for (int b=0; b<64; ++b)//Here I don't understand because if you're looking
>for the diagonal state you should have 256 state, so could you explain why do
>you use that? Thank you very much.

Yes, this is because although the rank has an 8 bit state it only requires the
inner 6 bits to determine the attack status.

The idea is that it doesn't matter to the attacks of a rook on e5 if there is a
piece on a5 or h5, if the file is otherwise empty they will be attacked.

This is good trick used by everybody I think, it cuts down the size of the table
by a factor 4 with no loss of information.

>Then I want to know why when you shift (I am still talking about bishop) is
>there a bit that will go out the bitboard? So if you look at the both SHIFT
>arrays and apply that index a bit will go out the bitboard. I wish to receive
>some explanation.

I don't fully understand the question, can you give a line number?

There is a wrap-around problem for shifting with anything but multiples of 8,
e.g. shifting +-1 or +-7 creates odd effects, if you don't mask out the correct
file things will "enter" from the other side of the board.

>The less important doubt is:
>
>const BitBoard A1 = 0x0000000000000001;
>const BitBoard B1 = 0x0000000000000002;
>const BitBoard C1 = 0x0000000000000004;
>const BitBoard D1 = 0x0000000000000008;
>
>I deduce that it's like mask[i], but you don't keep an array. But what kind of
>syntax is it? THank you.

This is hexidecimal notation, for 8 bit integers, I don't even know what it
would look like in ANSI C, but the above works with microsofts compilers.

The mask[] array is the same, but initialized later so I cannot use it to
initialize the squares.
Of course it would be smarter to declare mask[] as constant and initialize with
the above constants, must not have thought of that when I wrote it :)

>The last doubt is why do you use a bit board where the a column is on the
>rhight?

Do you mean the 90 degree rotated board?
This is for indexing the attack table, to get the status of a file attack.

With files the relevant bits gets scattered, only with ranks do they lie next to
eachother, so we rotate it 90 degrees and makes files into ranks and the trick
can be applied.

-S.
>Thank you very much for your time.
>Maurizio Di Vitto.



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.