Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Thanks a lot to Mr Wegner. Doubt

Author: Zach Wegner

Date: 16:52:27 12/06/03

Go up one level in this thread


On December 05, 2003 at 10:30:19, Maurizio Di Vitto wrote:

>I want to thanks Mr Wegner for all the explnation. I have two questions.
>It was about the initialization of rank_file[64][256].
>(your code)
>UINT64 o, m;
>int x, y;
>for (x = 0; x < 64; x++)
>{
>    for (y = 0; y < 256; y++)
>    {
>        o = y << (x & ~7);/*same as y << (8 * (x / 8))*/
>        rankattacks[x][y] = 0;
>        m = mask[x];
>        while (m && !(m & o))
>        {
>            m <<= 1;
>            rankattacks[x][y] |= m;
>        }
>        m = mask[x];
>        while (m && !(m & o))
>        {
>            m >>= 1;
>            rankattacks[x][y] |= m;
>        }
>    }
>
>
>If the state is 0, the bitboard o will be ...... 00000000, so the operation m<<1
>or m>>1 will continue until the bitboard finish because m&o will be equal to
>zero, should I control if I reach the end of the rank(or file)? It seems to be a
>stupid question.

Remember, there are no stupid questions! Yes, that is correct. I made a mistake
in that after m is shifted left or right, it should be ANDed with a mask that
has all bits set except the file on the opposite side of the board. Or you could
use a different mechanism, such as a counter. Try it out and see!

>
>I red your explanation about the file_attack[64][256]. To do that I used a
>bitboard called keep_value where I'll memorize the state (in your code is o)
>with a shift operation, then I initialized the file_attacks[square][state]=0,
>m=mask[rotated90r[square]], and then
>
>int up=8;
>
>while(m & (m&keep_value)==0)
>{
>m>>1;
>file_attacks[square][state]|=mask[square+up];<--/*in this part I receive an*/
>up+=8                                           /*access violation error*/
>}
>...........
>is it a right way and should I control the end of the rank or file?

Same as above, should be ANDed with a mask, or something similar.

>Thanks o lot for your time.
>Maurizio Di Vitto.

No problem. I like teaching :)

Regards,
Zach



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.