Computer Chess Club Archives


Search

Terms

Messages

Subject: A question about move generators for bishops and rooks

Author: Vaclav Visnadjek

Date: 15:15:40 04/06/04


Last year, the following occurred to me:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
BITBOARD *bishopmoves(POSITION *posit)
{
bishmoves=calloc(64,sizeof(BITBOARD));
int bishmovsq[28]={7,  14,  21,  28,  35,  42,  49,
                   9,  18,  27,  36,  45,  54,  63,
                  -7, -14, -21, -28, -35, -42, -49,
                  -9, -18, -27, -36, -45, -54, -63};
int h;
int i;
for (h=0; h<64; h++)
{
   for (i=0; i<28; i++)
   {
        if (h+bishmovsq[i]>=0 &&
             h+bishmovsq[i]<64 &&
                  ((h+bishmovsq[i])/8+(h+bishmovsq[i])%8)%2 == ((h/8)+(h%8))%2)
        {
             bishmoves[h] |= mask[h+bishmovsq[i]];
             if ((mask[h+bishmovsq[i]] & posit->allpieces) != 0)
             {
                  i = (7 * (1 + i/7))-1;
             }
        }
   }
}
return(bishmoves);
}

BITBOARD *rookmoves(POSITION *posit)
{
rkmoves=calloc(64,sizeof(BITBOARD));
int rookmovsq[28]={1,   2,   3,   4,   5,   6,   7,
                   8,  16,  24,  32,  40,  48,  56,
                  -1,  -2,  -3,  -4,  -5,  -6,  -7,
                  -8, -16, -24, -32, -40, -48, -56};
int h;
int i;
for (h=0; h<64; h++)
{
   for (i=0; i<28; i++)
   {
        if (h+rookmovsq[i]>=0 &&
             h+rookmovsq[i]<64 &&
                  ((h+rookmovsq[i])/8 == h/8 || (h+rookmovsq[i])%8 == h%8))
        {
             rkmoves[h] |= mask[h+rookmovsq[i]];
             if ((mask[h+rookmovsq[i]] & posit->allpieces) != 0)
             {
                  i = (7 * (1 + i/7))-1;
             }
        }
   }
}
return(rkmoves);
}
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
With all the necessary adjustments, can them be used as an alternative for
rotated bitboards? If so, could the main idea help to increase the speed of
calculations?



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.