Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: A question about move generators for bishops and rooks

Author: Robert Hyatt

Date: 17:57:07 04/06/04

Go up one level in this thread


On April 06, 2004 at 18:15:40, Vaclav Visnadjek wrote:

>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?


The point of rotated bitboards is that there are no loops for each direction.
So I don't quite understand your question...




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.